A loop is a sequence of instructions that is repeated until a certain condition is reached. If you want to repeat some code many times, then a loop can help you out which is what they are used for. There are three types of loops you can use to repeat some code: for loop, while loop, do-while loop. The “for” loop is used to when you want to run the code a specific amount of times. The while loop is used to repeat a section of code an unknown number of times until a specific condition is met.