Skip to content

Commit

Permalink
Update app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rokk1t authored Nov 14, 2023
1 parent bd4582b commit 5a72f70
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ const divideJS = document.getElementById("divide-html");
let actionJS = "+";

//! functions
plusJS.onclick = function() {
plusJS.onclick = function () {
actionJS = "+";
};
minusJS.onclick = function() {
minusJS.onclick = function () {
actionJS = "-";
};
multiplyJS.onclick = function() {
multiplyJS.onclick = function () {
actionJS = "*";
};
divideJS.onclick = function() {
divideJS.onclick = function () {
actionJS = "/";
};

Expand All @@ -35,14 +35,18 @@ function resultPrint(_result) {
function compute(_number1, _number2, _symbol) {
const number1 = Number(_number1.value);
const number2 = Number(_number2.value);
return _symbol === '+' ? number1 + number2 // true
: _symbol === '-' ? number1 - number2 // true
: _symbol === '*' ? number1 * number2 // true
: _symbol === '/' && number2 !== 0 ? number1 / number2 // true
: null;
}
return _symbol === "+"
? number1 + number2 // true
: _symbol === "-"
? number1 - number2 // true
: _symbol === "*"
? number1 * number2 // true
: _symbol === "/" && number2 !== 0
? number1 / number2 // true
: null;
}

submitJS.onclick = function () {
const result = compute(input1JS, input2JS, actionJS);
resultPrint(result);
};
};

0 comments on commit 5a72f70

Please sign in to comment.