The essence of the task consists in accepting the age value via the prompt method, and then outputting the line with the necessary case for this very number. The code contains operand%, which, in theory, should read the remainder of the division by 10 and output the necessary information. In addition, I used the break construct to prevent the browser from displaying the message "you are the wrong age" years old, and then said that an error occurred. But, unfortunately, I added something superfluous and now the browser does not display anything.
let age; age = prompt('Введите число, не превышающее 120...'); while (age !== "" && age > 0 && typeof (age) == "number") { if (age % 10 === 0) { document.write('<b>' + 'Вам ' + '</b>' + '<b>' + 'лет' + '</b>'); } if (age % 2 === 0 && age / 3 === 0) { document.write('<b>' + 'Вам ' + '</b>' + '<b>' + 'года' + '</b>'); } if (age % 2 === 1) { document.write('<b>' + 'Вам ' + '</b>' + '<b>' + 'год' + '</b>'); } else { if (age < 0) { document.write("Возраст не может быть меньше нуля!"); break; } if (typeof(age) !== "number") { document.write('<b>' + 'Это не число!' + '</b>'); break; } } break; }
'age'
is a string. Andage
is a variable with the value entered. - u_mulder