I was trying to get the total of iterations in a for loop on Javascript using node.js. Here is my code
var sum = 0;
for (itr=1; itr<=5; itr++) {
var lt = 8;
var sum = sum+lt;
console.log(sum);
}
So what I get here is a list of values as the output. How do I get the last value (the total of all iterations) 40 as a single output. Can someone please guide me through this?