math operations applied to number
For today's challenge we will cover the basics of javaScript applied to the web
- Variables;
- Math operations;
- Comparative operators;
- Parole.
The code for the following operations
- The sum of the two numbers;
let sun = firstNumber + secondNumber
- The subtraction of the two numbers;
let sub = firstNumber - secondNumber
- The multiplication of the two numbers;
let mul = firstNumber * secondNumber
- The division of the two numbers;
let div = firstNumber / secondNumber
- The remainder of the division of the two numbers;
let rem = firstNumber % secondNumber
For greater challenge the code will check the following conditions
- Check if the sum of the two numbers is even or odd;
if (sun % 2 == 0) {
console.log("The sum of the two numbers is even")
} else {
console.log("The sum of the two numbers is odd")
}
- Check whether the two numbers entered are the same or different.
if (firstNumber > secondNumber) {
alert(`The first number is greater than the second`)
} else if (firstNumber < secondNumber) {
alert(`The first number is less than the second`)
} else {
alert(`The numbers are the same`)
}