I've been experimenting with for loops, mostly with a condition 'less than or equal'. However, I wanted to make the condition of a for loop so that the number in the initialization is bigger than that one in the condition. When I ran the code, it didn't work. And when I added the bigger than or equal operator, it crashed; here's the code:
//loop n1
for (let i = 0; i > 4; i++) {
console.log(i);
}
//loop n2
for (let i = 0; i >= 4; i++) {
console.log(i);
//loop n3
for (let i = 0; i = 4; i++) {
console.log(i);
None of these worked, and the last one crashed. I don't get it; according to my logic, loop n3 should have stopped when "i" is equal to 4, but no, it crashed. And loop n1 should've stopped when "i" is more than 4.
Can anybody explain this to me?
Thanks