I am having a problem in writing a javascript for finding the sum of the first 10 natural numbers. I have written the code with a while function and it is working well:
var total = 0, count = 1;
while (count <= 10) {
total += count;
count += 1;
}
console.log(total);
I am now wondering how you can do this using a for loop, if it is possible. Any help?
for? MDN provides all the documentation you need: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…