// let's try a prompt.
var input = prompt("The prompt goes here",
"this is default value if you don't enter anything");
document.write("You entered: " + input + "<br><br>");
// We can read in a number as well!
// Read in a string, then convert it to integer.
// Let's write their response in boldface using <b> and </b>.
input = prompt("Okay, please enter a number this time...", "0");
document.write("You entered... <b>" + input + "</b><br><br>");
var inputNumber = parseInt(input);
////////////////////////////////////////////////////////
// In Javascript, if we want to do something repeatedly,
// we use a "for" loop.
document.write("Let's count up to the number you entered....<br>");
for (i = 1; i <= inputNumber; ++i)
{
document.write(i + "<br>");
}
document.write("<br><br>");
/////////////////////////////////////////////////////////
// Let's do some arithmetic on input values.
input = prompt("How much does an apple cost?", "0.00");
var applePrice = parseFloat(input);
input = prompt("How many apples do you want?", "0");
var numApples = parseInt(input);
document.write(numApples + " apples at " + applePrice + " each will cost $" +
applePrice * numApples + "<br>");