%%html
<h1 id="title">Math Test</h1>
<img alt="math" src="https://www.bwseducationconsulting.com/wp-content/uploads/2020/08/bws-maths-tutoring.jpg" width="250" height="175">
<div>
<p>
<a href="https://www.youtube.com/watch?v=igcoDFokKzU">If you need help</a>
</p>
</div>
<div id="Test">
<label for="addition">15 + 3 =</label>
<input type="number" id="addition" name="addition">
<label for="subtraction">15 - 3 =</label>
<input type="number" id="subtracion" name="subtraction">
<label for="multiplication">15 x 3 =</label>
<input type="number" id="multiplication" name="multiplication">
<label for="division">15/3 =</label>
<input type="number" id="division" name="division">
</div>
<button type="button" onclick="submitResponse()">Submit</button>
<div id="answers"></div>
<script>
function submitResponse(){
var num15 = 15
var num3= 3
//show answers in console when clicking submit (data types)
console.log("These are the answers to the test. Please check your responses!")
console.log("15 + 3 = ")
console.log(num15 + num3)
console.log("15 - 3 = ")
console.log(num15 - num3)
console.log("15 x 3 = ")
console.log(num15 * num3)
console.log("15/3 = ")
console.log(num15 / num3)
//Print answers when clicking submit (dom)
var additionAnswer = num15 + num3;
var subtractionAnswer = num15 - num3;
var multiplicationAnswer = num15 * num3;
var divisionAnswer = num15 / num3;
var answersDiv = document.getElementById("answers");
answersDiv.innerHTML = `
<p>15 + 3 = ${additionAnswer}</p>
<p>15 - 3 = ${subtractionAnswer}</p>
<p>15 x 3 = ${multiplicationAnswer}</p>
<p>15 / 3 = ${divisionAnswer}</p>
`;
}
</script>
JS Basics Individual Test • 3 min read
Description
An introduction to key topics in Web Programming