If the variable totalMonths has a string value of "13", what string will the alert display after the code has finished executing?

var years = parseInt ( totalMonths / 12 );
var months = totalMonths % 12;
if ( years == 0 ) {
alert ( months + " months.");
} else if ( months == 0 ) {
alert ( years + " years");
} else {
alert ( years + " years, and " + months + " months.";
}

What do you think it will be?

1 Like