## About this lesson

Create pages for Subtraction, Multiplication, and Division and finish the app.

## Exercise files

Download this lessonâ€™s related exercise files.

Finishing Up.docx199.8 KB Finishing Up - Solution.docx

200.1 KB

## Quick reference

### Finishing Up

Let's finish the app up!

### When to use

We're at the end!

### Instructions

Now we just need to create pages for Subtraction, Multiplication, and Division. Copy and paste our Addition code into each one, and then just change the plus signs + to subtraction signs, multiplication signs, and division signs accordingly.

Our finished code including links to all pages looks like this:

<html>

<head>

<title>Addition Flashcards</title>

<script>

var number1 = Math.floor((Math.random() * 10) + 1);

var number2 = Math.floor((Math.random() * 10) + 1);

var correctAnswer = number1 + number2;

var output;

</script>

</head>

<body>

<a href="addition.html">Addition</a> |

<a href="subtraction.html">Subtraction</a> |

<a href="multiplication.html">Multiplication</a> |

<a href="division.html">Division</a>

<h1>Addition Flashcards</h1>

<h1 id="numbers">

<script>

document.write(number1 + " + " + number2);

</script>

</h1>

<input id="answer">

<button type="button" onclick="userAnswer();">Submit Answer</button>

<button type="button" onclick="nextCard();">Next Card</button>

<p id="output"></p>

<script>

function userAnswer(){

var userAnswer = document.getElementById("answer").value;

if (isNaN(userAnswer)) {output = "Hey! That's not a number, try again!";} else {

if (userAnswer == correctAnswer) {output = "Correct! " + number1 + " + " + number2 + " = " + correctAnswer;} else {output = "Wrong! " + number1 + " + " + number2 + " is not " + userAnswer;}

}

document.getElementById("output").innerHTML = output;

}

function nextCard(){

document.getElementById("output").innerHTML = "";

document.getElementById("answer").value = "";

number1 = Math.floor((Math.random() * 10) + 1);

number2 = Math.floor((Math.random() * 10) + 1);

correctAnswer = number1 + number2;

document.getElementById("numbers").innerHTML = (number1 + " + " + number2);

}

</script>

</body>

</html>

### Hints & tips

- Be sure to add links to all the other pages of your app!

Lesson notes are only available for subscribers.