Created
February 17, 2023 23:10
-
-
Save schesnowitz/8b06415b3f6a1c182533b3fbd7e2bd9e to your computer and use it in GitHub Desktop.
random math generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let x = Math.floor(Math.random() * 100 + 1); | |
let y = Math.floor(Math.random() * 50 + 1); | |
sum = (x + y).toString(); | |
sumOutput = (`${x} + ${y} = ${sum}`); | |
remainder = (x % y).toString(); | |
remainderOutput = (`${x} % ${y} = ${remainder}`); | |
product = (x * y).toString(); | |
productOutput = (`${x} X ${y} = ${product}`); | |
quotient = (x / y).toString(); | |
quotientOutput = (`${x} / ${y} = ${quotient}`); | |
difference = (x - y).toString(); | |
differenceOutput = (`${x} - ${y} = ${difference}`); | |
selection = difference | |
function printTheResults() { | |
if (selection === sum) { | |
return sumOutput | |
} else if (selection === remainder) { | |
return remainderOutput | |
} else if (selection === product) { | |
return productOutput | |
} else if (selection === quotient) { | |
return quotientOutput | |
} else if (selection === difference) { | |
return differenceOutput | |
} | |
} | |
console.log(printTheResults()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment