The Difference Between For Loops and While Loops in JavaScript
As I know and learned we use for loop when we already know how many times we want to loop through something And we use while loop because we don't know how many times we want to loop through something look at these examples for (let i=0; i < 7; i++) { console.log('Hello World'); } we have a variable equal to 0 and this loop helps us to print "Hello World" 7 times so here we know we want "Hello World" to be printed 7 times But in while loop look at the example below let x = 0; while (x < 4) { x++; console.log ("Hello World") } Do you see it? There was no difference between these two loops In both of them, we know exactly how many times we want something to be repeated Even in while loop we know we want "Hello World" to be printed 4 times so how should I know which one is better and where and when? can someone clarify it for me? I'm so confused I've seen resources in Javascript.info, solo learn, Mozilla website and youtube and many other websites but I can't understand and see the difference between these two loops please and please I beg you guys someone explain