𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗟𝗼𝗼𝗽𝘀

You repeat tasks in code with loops.

For Loop Use this when you know the number of repeats.

Loop Scope Declare variables with let inside the loop. These stay inside. Declare them outside. These stay outside.

While Loop This loop runs while a condition is true. The code repeats until the condition is false.

Do While Loop This loop runs the code first. It checks the condition after. The code runs at least once.

Warning Update your variable inside the loop. Your loop will never end without an update.

Source: https://dev.to/dev_saravanan_journey/javascript-loops-31lh