DEV Community

Discussion on: Basic math operations on different data types in JavaScript

Collapse
 
justmario profile image
Just-Mario

Hey thanx for this. I am new to JS and I hit problem so I need help understanding this while loop.

Could you please help me understand this:

Var number =1;
Var sum = 0;
While(number < 11){
Sum += number;
++number;
}
Console.log(sum); //Displays 55

My question is how does it get to 55?
I'd appreciate it if you can break it down for this Newby.

Thanx in advance m