Javascript Notes – Loops

DRY code is an acronym for Don’t Repeat Yourself. It describes the philosophy of writing code intelligently with loops instead of typing out repetitive code over and over.

While Loops


//run some code


Adding to the count

For example if we want to run a simple loop that counts to ten we could do the following:

What if we wanted to add more than 1 to the count, what if we wanted to add 2?

We set count+=2

Printing each character in a string



This takes advantage of the .length property and another big concept which is the [indexwhich will select whichever character or object from an array that is defined by the brackets.

Some additional examples:

+ There are no comments

Add yours