Skip to content

Instantly share code, notes, and snippets.

@jessedhillon
Created January 14, 2015 03:52
Show Gist options
  • Save jessedhillon/e40ca83e29a04b311e19 to your computer and use it in GitHub Desktop.
Save jessedhillon/e40ca83e29a04b311e19 to your computer and use it in GitHub Desktop.
Printing squares in a loop
// 1. Prompt user for a number, n
// 2. Print the square of every number between 0 and n
var number = parseInt(prompt("Give me a number")); // prompt is a built-in function
for(var i = 0; i <= number; i++) {
console.log(i * i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment