Skip to content

Instantly share code, notes, and snippets.

@Taiiwo
Last active December 25, 2015 07:39
Show Gist options
  • Save Taiiwo/6940342 to your computer and use it in GitHub Desktop.
Save Taiiwo/6940342 to your computer and use it in GitHub Desktop.
Asks for 10 numbers, then adds them together.
<script>
var num = [];
var total = 0;
for (var i = 0; i < 10; i++) {// for i as each number between 0 and 9:
num.push(parseInt(prompt()));// ask for a number
}
for (i=0; i < num.length; i++){// for i as each number in num.length:
total += num[i];// total equals itself plus the current number in num
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment