let num1 = prompt("Enter the first number: ");
let num2 = prompt("Enter the second number: ");
let operator = prompt("Enter the operator (+, -, * or /): ");
if (operator === "+") {
let result = parseInt(num1) + parseInt(num2);
alert("The result is: " + result);
} else if (operator === "-") {
let result = parseInt(num1) - parseInt(num2);
} else if (operator === "*") {
let result = parseInt(num1) * parseInt(num2);
} else if (operator === "/") {
let result = parseInt(num1) / parseInt(num2);
} else {
alert("Invalid operator!");
}
Мне на английском удобнее
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
let num1 = prompt("Enter the first number: ");
let num2 = prompt("Enter the second number: ");
let operator = prompt("Enter the operator (+, -, * or /): ");
if (operator === "+") {
let result = parseInt(num1) + parseInt(num2);
alert("The result is: " + result);
} else if (operator === "-") {
let result = parseInt(num1) - parseInt(num2);
alert("The result is: " + result);
} else if (operator === "*") {
let result = parseInt(num1) * parseInt(num2);
alert("The result is: " + result);
} else if (operator === "/") {
let result = parseInt(num1) / parseInt(num2);
alert("The result is: " + result);
} else {
alert("Invalid operator!");
}
Мне на английском удобнее