Skip to content

Commit

Permalink
calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulyana0505 committed Sep 26, 2023
1 parent b8f3f6d commit 01d97f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h2 id="title_2">A little bit less pink title</h2>

<button name="button_1" onclick="onClickButton(this)">Click-click-click</button>
<br>
<button name="button_2" onclick="userCalculate(this)"></button>
<button name="button_2" onclick="userCalculate()">Calculate button</button>
<img src="haha.jpg"
width="685"
height="618">
Expand Down
12 changes: 10 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ function onClickButton(el) {
el.style.color = "#4b0082";
}

function userCalculate(a) {
prompt("Enter any two numbers: ");
function userCalculate(a, b) {
let a = +prompt("Enter first number: ");
let b = +prompt("Enter second number: ");
let c = a + b;
let sum = +prompt("Enter sum of those two numbers: ");
if (c == sum) {
alert("Congratulations! You're absolutely right :)")
} else {
alert("Nope. You've made a mistake. Please try again to count another numbers")
}
}

0 comments on commit 01d97f8

Please sign in to comment.