It's crashing my web browser every time


#1

Does anyone else have this problem as well?

for (var i=1; i <100; i -= 5) {
console.log(i);
}

When I hit save and continue, it'd just crash my chrome browser...


#2

@datawhiz28971,

for ([initialization]; [condition]; [final-expression]) {
   statement
}

In your initialzation you give i the number Value 1
then
in your condition you check if i is =less than= 100
in your final-expression you then substract 5 from the 1, leaving you with -4

in your condition you check if i is =less than= 100
in your final-expression you then substract 5 from the 1, leaving you with -9

in your condition you check if i is =less than= 100
in your final-expression you then substract 5 from the 1, leaving you with -14

in your condition you check if i is =less than= 100
in your final-expression you then substract 5 from the 1, leaving you with -19

untill your Browser crashes....

Solution
change the condition into i > -10
or
leave the condition as is,
and change the final-expression into i += 5

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for