Skip to content

liad calculator#4

Open
Liaddj wants to merge 1 commit into
ColmanDevClubORG:mainfrom
Liaddj:main
Open

liad calculator#4
Liaddj wants to merge 1 commit into
ColmanDevClubORG:mainfrom
Liaddj:main

Conversation

@Liaddj

@Liaddj Liaddj commented Nov 28, 2025

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 comment, please make sure to apply them for every place in your code

Also, why did you changed the design so much? your design is totally differ from the original?

Comment thread index.html
<button class="number">1</button>
<button class="number">2</button>
<button class="number">3</button>
<button id="add">+</button>

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 do you need id in here? you can use classes for everything

Comment thread script.js
@@ -0,0 +1,77 @@
let firstNum = '';
let secondNum = '';
let operator = null;

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 do you need to initialize this as null? the default undefined wont be good here?

Comment thread script.js
let clear_page = document.querySelector('#clear')


numbers.forEach(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.

Good use in the loop here

Comment thread script.js
firstNum += value;
display.textContent = firstNum;
} else {
secondNum += value;

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.

With early return you can make this shorter :

    if (!operator) {
      firstNum += value;
      display.textContent = firstNum;
      return
      secondNum += value;
      display.textContent = secondNum;

You will have to use another type of loop tho because you cannot exit the loop iteration when using forEach

Comment thread script.js
});

plus.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.

Do you think that you can combine those 4 functions into a single one? they are kind of the same

Comment thread script.js
equal.addEventListener('click', function() {
let result;
if (operator === '+') {
result = Number(firstNum) + Number(secondNum);

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.

Number of the default empty string will result on 0, so why not start with 0 for first number?

Comment thread style.css
--display-color: #ffffff;
--text-color: #111827;
body {
position: relative;

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.

How is this helping you ?

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.

Really helpful and thank you very much

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 wanted to know why you chose to do so, is it because of you wanted the children be absolute? something else?

Comment thread style.css
font-weight: 700;
margin-top: 30px;
margin-bottom: 25px;
color: #333;

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.

Colors should come from css variables

Comment thread style.css
text-align: center;
font-size: 2.1rem;
font-weight: 700;
margin-top: 30px;

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 not to mix different units, stick to one

Comment thread style.css
flex-direction: column;
gap: 15px;
.container {
position: fixed;

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.

Do you think you can do the same with flex?

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.

of course tust me...

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, flex will be much better and modern approach

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