How to return -1 value? : <p>Write a function called day_diff that takes four scalar positive integer inputs, month1, day1, month2, day2. These represents the birthdays of two children who were born in 2015. The function returns a positive integer scalar that is equal to the difference between the ages of the two children in days. Make sure to check that the input values are of the correct types and they represent valid dates. If they are erroneous, return -1. An example call to the function would be</p>

<blockquote>
  <blockquote>
    <p>dd = day_diff(1,30,2,1);
    which would make dd equal 2. You are not allowed to use the built-in function datenum or datetime.</p>
  </blockquote>
</blockquote>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="true">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function dd = day_diff(month1, day1, month2, day2)
if (month1 &amp;&amp; month2 &gt; 0) || (month1 &amp;&amp; month2 &lt;= 12)
    if month1 == 1 &amp;&amp; month2 == 1
        if day1 == day2
            total1 = day1;
            total2 = day2;
        elseif day1 ~= day2
            total1 = max(day1,day2);
            total2 = min(day1,day2);
        end
    elseif month1 == 1 &amp;&amp; month2 == 2
        total1 = day1;
        total2 = day2 + 31;
    elseif (month1 == 2 &amp;&amp; day1 &lt;= 28) &amp;&amp; month2 == 1
        total1 = day1 + 31;
        total2 = day2;
    elseif month1 == 1 &amp;&amp; month2 == 12
        total1 = day1;
        total2 = day2 + 334;
    elseif month1 == 2 &amp;&amp; month2 == 3
        total1 = day1 + 31;
        total2 = day2 + 59;
    elseif month1 == 7 &amp;&amp; month2 == 9
        total1 = day1 + 181;
        total2 = day2 + 243;
    else
        return
    end
end
dd = (max(total1,total2)) - (min(total1,total2));</code></pre>
</div>
</div>
</p>
