Skip to content

Commit

Permalink
added addAddition function, added negative numbers error
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiMorozov88 committed Nov 18, 2023
1 parent 2c7d4e9 commit 426c128
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ function getAbsoluteTime() {
const date = new Date();
return date.getTime();
}
function getAddition(number) {
if (number <= 1) {
return 'game';
}
return 'games';
}
function showResult() {
const timeStart = getAbsoluteTime();
let result;
Expand Down Expand Up @@ -56,14 +62,20 @@ function showResult() {
result = firstNumber ** secondNumber;
break;
}
resultContainer.innerText = `${result}`;
resultContainer.innerText = `${result} ${getAddition(result)}`;

if (result > 100) {
resultContainer.innerText = 'Error';
commentContainer.innerText = 'Too many games';
commentContainer.classList.add('comment-container--error');
return;
}
if (result < 0) {
resultContainer.innerText = 'Error';
commentContainer.innerText = 'Negative count of games is not possible';
commentContainer.classList.add('comment-container--error');
return;
}
resultContainer.classList.add('calculator__result--calc');
for (let count = 0; count < 10000000; count++);
const timeFinish = getAbsoluteTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
min-width: 100px;
height: 50px;
font-size: 20px;
padding: 0 5px;
justify-content: center;
align-items: center;
color: #C9C2C2;
Expand Down

0 comments on commit 426c128

Please sign in to comment.