Skip to content

Almog Lavi - Fixed#11

Open
Lavi2910 wants to merge 4 commits into
ColmanDevClubORG:mainfrom
Lavi2910:main
Open

Almog Lavi - Fixed#11
Lavi2910 wants to merge 4 commits into
ColmanDevClubORG:mainfrom
Lavi2910:main

Conversation

@Lavi2910

Copy link
Copy Markdown

No description provided.

@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

Comment thread script.js Outdated
@@ -0,0 +1,73 @@

let operator = undefined;

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.

undefined is the default value of let variables, you could simply let operator

Comment thread script.js

number.forEach((num) => {
num.addEventListener('click', function() {
let digit = parseInt(num.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.

This could be NAN so you should add a check for it

Comment thread script.js Outdated
number.forEach((num) => {
num.addEventListener('click', function() {
let digit = parseInt(num.textContent);
if (operator===undefined)

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.

You could also write if(!operator)

Comment thread script.js
let digit = parseInt(num.textContent);
if (operator===undefined)
{
x=x*10+digit;

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.

Try to save 10 into a constant vriable, random numbers in the code are called magic numbers, very confusing

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

didn't understand what's the confusing part

Comment thread script.js
{
x=x*10+digit;
display.textContent = x;
return;

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.

Good practice

Comment thread script.js Outdated
})

multiply.addEventListener('click', function() {
operator = '*'

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.

Can you think of a way to only write 1 event listeners for all of the operators?

Comment thread script.js Outdated

clear.addEventListener('click',function(){
resetAll();
display.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.

Why not insert this line into resetAll function?
From the name the function should reset all, the display as well

Comment thread script.js Outdated

equal.addEventListener('click',function() {
let result;
if (operator === '+')

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.

Save your strings into constant variable or even an object for easy access

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.

3 participants