While loops are based on a condition and run while that condition is equal to true. There are two main types of loops used in JavaScript: while loops and for loops. In addition, what if you aren’t sure how long the list will be? Here you could use a loop that repeats a similar block of code merging each list item. You could write a line of code for every name, but that could require hundreds of lines of code if the list is long. They are useful for many repetitive programming tasks.įor example, you may have two lists of names-first names and surnames-that you want to merge into a list of full names. Loops repeat the same block of code until a certain condition is met.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |