creating calc#19
Open
omrialoni16-wq wants to merge 1 commit into
Open
Conversation
Tamir198
requested changes
Dec 8, 2025
| <button class="number" id="number-9">9</button> | ||
| </div> | ||
| <div class="row"> | ||
| <button class="number" id="number-4">4</button> |
Member
There was a problem hiding this comment.
You dont really need both id and class
|
|
||
| </html> No newline at end of file | ||
| <script> | ||
| const clear = document.querySelector("#clear"); |
Member
There was a problem hiding this comment.
The js should come from js file loaded into this HTML page
| const equal = document.querySelector("#equal"); | ||
| let x = 0; | ||
| let y = 0; | ||
| let z = 0; |
Member
There was a problem hiding this comment.
Can you give your variable better names? they should indicate what they are doing and x y z not so much
| let x = 0; | ||
| let y = 0; | ||
| let z = 0; | ||
| let sign = null; |
| numbers.forEach((number) => { | ||
| number.addEventListener("click", () => { | ||
| if (sign) { | ||
| y = y * 10 + parseInt(number.textContent); |
Member
There was a problem hiding this comment.
Save 10 inside a constant variable
| }); | ||
|
|
||
| clear.addEventListener("click", () => { | ||
| display.innerHTML = " "; |
Member
There was a problem hiding this comment.
We never want to use innerHTML its very dangerous and bad practice.
Use text content instead
| sign = null; | ||
| }); | ||
|
|
||
| operators.forEach((operator) => { |
Member
There was a problem hiding this comment.
Good practice in here to use array of operates
|
|
||
| operators.forEach((operator) => { | ||
| operator.addEventListener("click", () => { | ||
| if (sign == null) { |
| display.textContent = z; | ||
| }); | ||
| </script> | ||
| <!-- <script src="script.js"></script> --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.