JSFiddle - React, Tailwind, and code Playground
JavaScript
var x = Number(prompt("Введите x",1)),
operation = prompt("Введите операцию", '-'),
y = Number(prompt("Введите y",1));
function calc( x, y, operation) {
var result;
if (operation === "+") {
result = x + y;
} else if (operation === "-") {
result = x - y;
} else if (operation === "*") {
result = x * y;
} else if (operation === "/") {
result = x / y;
}
return result;
};
alert(calc( x, y, operation));