Skip to content

Lidor-Calculator#26

Open
Lidor-Tal wants to merge 1 commit into
ColmanDevClubORG:mainfrom
Lidor-Tal:homework/calculator-extension/Lidor-Tal
Open

Lidor-Calculator#26
Lidor-Tal wants to merge 1 commit into
ColmanDevClubORG:mainfrom
Lidor-Tal:homework/calculator-extension/Lidor-Tal

Conversation

@Lidor-Tal

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 index.html
<button class="number" id="number-3">3</button>
</div>
<div class="row operations">
<button id="add" onclick="getOperator(`+`)">+</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.

Dont mix html and js, add your functionality from the js file

Comment thread script.js
@@ -0,0 +1,85 @@
let input1 = "",
input2 = "",
result = 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.

result just like this will be undefined is it ok ?
If yes yo u dont need to explicitly give this the value

Comment thread script.js
let display = document.querySelector(".display");

// # Get numbers from the user
numberButtons.forEach((btn) => {

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.

Comment like this are not helpful, the code should explain itself

Comment thread script.js
// # Get numbers from the user
numberButtons.forEach((btn) => {
btn.addEventListener("click", () => {
console.log("btn", btn);

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.

Remove those consoles

Comment thread script.js
});
});

// # Receive numbers and save them to the right input

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.

Same comment in here about comments in the code,

Comment thread script.js
function getNumbers(number) {
if (newNumbers) {
input1 += number;
display.textContent = input1;

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 can have early return in here to avoid using else

Comment thread script.js

// # Get the Operator and calculate the number
function getOperator(opr) {
if (newNumbers) {

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 entire if else could be a function and just call it

Comment thread script.js

// # Clear the date for another calculate
function clearAll(equal) {
if (equal !== "=") {

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 = into constant variable

Comment thread script.js
// # Clear the date for another calculate
function clearAll(equal) {
if (equal !== "=") {
display.innerHTML = "&nbsp;";

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.

Never use innerHTMl its very dangerous

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