Skip to content

Conversation

@lianhersh
Copy link

finished js

Copy link
Contributor

@GilHeller GilHeller left a comment

Choose a reason for hiding this comment

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

Overall nice job!
please see my comments

let tipAmout;
let total;

calcTip= (x) =>{
Copy link
Contributor

Choose a reason for hiding this comment

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

declare as a const. Also, give x a meaningful name

const calcTip = (x) => {
...
}

Comment on lines +27 to +28
tipAmountResult.innerText="$"+tipAmount.toFixed(2);
totalAmountResult.innerText="$"+total.toFixed(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

consider using createElement and appendChildinstead ofinnerHTML`

innerHTML has security vulnerability.

see https://medium.com/@jasen.miyamoto/appending-to-the-dom-and-the-dangers-of-using-innerhtml-debd77e53e70

.ptags {
padding-bottom: 30px;
font-weight: 900;
color: hsl(186, 14%, 43%);
Copy link
Contributor

Choose a reason for hiding this comment

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

flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
/* padding-left: 30px; */
Copy link
Contributor

Choose a reason for hiding this comment

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

remove comment

Comment on lines +36 to +47
if(!customValue || customValue<=0){
hoverWarning.style.display="block";
return;
}
hoverWarning.style.display="none";

tipAmount=(priceValue*customValue)/peopleValue;
total=(priceValue*(1+customValue))/peopleValue;


tipAmountResult.innerText="$"+tipAmount.toFixed(2);
totalAmountResult.innerText="$"+total.toFixed(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

This section repeating. Consider extract it to a function.

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