-
Notifications
You must be signed in to change notification settings - Fork 1
Lian calculator js #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
GilHeller
left a comment
There was a problem hiding this 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) =>{ |
There was a problem hiding this comment.
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) => {
...
}| tipAmountResult.innerText="$"+tipAmount.toFixed(2); | ||
| totalAmountResult.innerText="$"+total.toFixed(2); |
There was a problem hiding this comment.
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.
| .ptags { | ||
| padding-bottom: 30px; | ||
| font-weight: 900; | ||
| color: hsl(186, 14%, 43%); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use css variables
see https://www.w3schools.com/css/css3_variables.asp
| flex-direction: column; | ||
| justify-content: flex-start; | ||
| align-items: flex-start; | ||
| /* padding-left: 30px; */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
| 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); |
There was a problem hiding this comment.
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.
finished js