Ask Question
19 September, 12:33

If totalMonths has a string value of "13", what does the code that follows display? 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.");

}a) 1 years, and 1 monthsb) 1 year, and 1 monthc) 1 yearsd) 1 year

+4
Answers (1)
  1. 19 September, 12:38
    0
    The answer to this question is "Option a".

    Explanation:

    The description of the jа vascript code as follows:

    In the code, there is two variable defined that are "years and months". The years convert string value in number and calculate years and holds value in years variable and months variable calculate the moths and holds value in months variable. Then we use conditional statements in this statement we use two if blocks. In first if block we check that years variable value is equal to 0. if this condition is true. it will print months in the alert box. In second if block we check that if months variable value is equal to 0. if this condition is true. it will print years in the alert box. In else block, we use an alert box that prints years and months.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “If totalMonths has a string value of "13", what does the code that follows display? var years = parseInt (totalMonths / 12); var months = ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers