Skip to content

feat: calculator excercise tamar m.#21

Open
tamarmatza-commits wants to merge 1 commit into
ColmanDevClubORG:mainfrom
tamarmatza-commits:calculator_ex_2025_tamar
Open

feat: calculator excercise tamar m.#21
tamarmatza-commits wants to merge 1 commit into
ColmanDevClubORG:mainfrom
tamarmatza-commits:calculator_ex_2025_tamar

Conversation

@tamarmatza-commits

Copy link
Copy Markdown

Write the js for the calc.

Write the js for the calc.

@Tamir198 Tamir198 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey left you some comments, good work overall

Comment thread script.js
let result;

const display = document.querySelector('.display');
const numbers = document.querySelectorAll('.number');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good practice to get all of the numbers at once

Comment thread script.js

numbers.forEach((numButton) => {
numButton.addEventListener('click', () => {
if (display.textContent === '0') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 should be saved inside constant variable

Comment thread script.js
button.addEventListener('click', () => {
calc();

operator = button.textContent;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a null check on the operator

Comment thread script.js
result = result * parseInt(operand);
break;
case '/':
result = result / parseInt(operand);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will you see in case of number/0?

Comment thread script.js
operand = '';
result = 0;

display.textContent = '0';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you would removed the above 0 into constant you could reuse it in here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants