## Exercise Set 8

### Exercise 1 of 6

Watch the for loop video. Write the initialization to show the numbers 0 through 9.

HTML

```<button id="zeroNineButton">Show numbers 0 through 9</button>
<p id="zeroNineParagraph">Numbers:</p>
```

JavaScript

```let zeroNineButton = document.getElementById(`zeroNineButton`)
let zeroNineParagraph = document.getElementById(`zeroNineParagraph`)

function showZeroNine() {
for (// your code will appear here; i < 10; i = i + 1) {
zeroNineParagraph.innerHTML = `\${zeroNineParagraph.innerHTML} \${i}`
}
}
```

Numbers:

### Exercise 2 of 6

Write the initialization to show the numbers 10 through 19.

HTML

```<button id="tenNineteenButton">Show numbers 10 through 19</button>
<p id="tenNineteenParagraph">Numbers:</p>
```

JavaScript

```let tenNineteenButton = document.getElementById(`tenNineteenButton`)
var tenNineteenParagraph = document.getElementById(`tenNineteenParagraph`)

function showTenNineteen() {
for (// your code will appear here; i < 20; i = i + 1) {
tenNineteenParagraph.innerHTML = `\${tenNineteenParagraph.innerHTML} \${i}`
}
}
```

Numbers:

### Exercise 3 of 6

Write the condition to say hello 10 times.

HTML

```<button id="helloButton">Say hello 10 times</button>
<p id="helloParagraph">Words:</p>
```

JavaScript

```let helloButton = document.getElementById(`helloButton`)
let helloParagraph = document.getElementById(`helloParagraph`)

function sayHello() {
for (let i = 0; // your code will appear here; i = i + 1) {
helloParagraph.innerHTML = `\${helloParagraph.innerHTML} hello`
}
}
```

Words:

### Exercise 4 of 6

Write the condition to show the numbers 0 through 9 in reverse order.

HTML

```<button id="reverseButton">Show numbers 0 through 9 in reverse</button>
<p id="reverseParagraph">Numbers:</p>
```

JavaScript

```let reverseButton = document.getElementById(`reverseButton`)
let reverseParagraph = document.getElementById(`reverseParagraph`)

function showReverse() {
for (let i = 9; // your code will appear here; i = i - 1) {
reverseParagraph.innerHTML = `\${reverseParagraph.innerHTML} \${i}`
}
}
```

Numbers:

### Exercise 5 of 6

Write the iteration to show the even numbers between 0 and 19.

HTML

```<button id="evenButton">Show even numbers between 0 and 19</button>
<p id="evenParagraph">Numbers:</p>
```

JavaScript

```let evenButton = document.getElementById(`evenButton`)
let evenParagraph = document.getElementById(`evenParagraph`)

function showEven() {
for (let i = 0; i < 20; // your code will appear here) {
evenParagraph.innerHTML = `\${evenParagraph.innerHTML} \${i}`
}
}
```

Numbers:

### Exercise 6 of 6

Show the squares of 0 through 9. Refer to this squares table.

HTML

```<button id="squaresButton">Show squares of 0 through 9</button>
<p id="squaresParagraph">Squares:</p>
```

JavaScript

```let squaresButton = document.getElementById(`squaresButton`)
let squaresParagraph = document.getElementById(`squaresParagraph`)