Javascript - The for Loop
Code Life
By Pierre Marsaa
Repeating Without Copy-Pasting
Imagine Pyrochu has to train 5 times. You could write the same console.log five times... but what about 100 times? Or 1000?
↗️
Loading editor...
↶
↷
A loop repeats a block of code for you. Here is the exact same result with a for loop:
↗️
Loading editor...
↶
↷
One block, five executions. Try changing 5 to 100 and run again: no copy-pasting needed!
Verify