One-line programs are not very interesting. When you put more than one statement into a program, the statements are executed, predictably enough, one at a time, from top to bottom. This program has two statements; the first one asks the user for a number, and the second one shows the square of that number:
var theNumber = Number(prompt("Pick a number", "")); alert("Your number is the square root of " + (theNumber * theNumber));
Number converts a value to a number, which is needed in
this case because the result of
prompt is a string value. There are
similar functions called
convert values to those types.
Sometimes, you do not want all the statements in your program to always ...