Loops are used to repeat statement.

For example, To output numbers from 0 to 100, without loop, there is only a way to print
each number using document.write or console.log, It means 100 lines of code needs to be written, to overcome the problem for repetitive tasks, loops are used.

Without loop Example

<script>
  document.write(1);
  document.write(2);
  document.write(3);
  document.write(4);
  .
  .
  .
  .
  document.write(100);
</script>

To print numbers till 100, each statement should be written one by one, but with loop, no need to do this long repetitive task.

With loop Example

<script>
let i;
for(i = 0; i < 100; i++)
{
  document.write(i);
}
</script>

Above example will print, numbers from 0 -100 using for loop, without repeating same set of statements, with lesser lines of code. Program become easier to understand and debugging become easier.

Javascript provide 5 different types of loop

for, while and do-while loop has three common parts

initializationstarting value, from where the loop starts
conditionHow many times loop will execute.
iterationincrement/decrement to continue loop cycles.