Just need to check that data user input on prompt is a number in Javascript
var userAge = prompt("Please enter your age", "");
if (typeof userAge == 'number') {
document.write("You are " + userAge + " years old.");
} else {
document.write('Please enter a valid number');
}
When I type my age, 28, to test, I expect that "You are 28 years old." will be printed to the document. However, it prints the else part of the code: "Please enter a valid number."