-
Notifications
You must be signed in to change notification settings - Fork 1
Functional calc roie raz #19
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
danielmargolin
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.
left some comment + plus I think there is a bug
please check
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.
Indentation problems. makes it harder to understand what's happening
| let customTip = 0; | ||
|
|
||
|
|
||
| document.getElementById('bill').addEventListener('input', function(event) { |
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.
Change the id to bill-input
makes it easier to understand the context
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.
stick with the syntax () => {} and not function() {}
| button.addEventListener('click', function(event) { | ||
| const buttons = document.querySelectorAll('.tip-button'); | ||
| buttons.forEach(btn => { | ||
| btn.style.backgroundColor = ''; // Reset background color |
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.
instead of changing the inline-css, change the class
| } | ||
|
|
||
| const resetCalc = () => { | ||
| location.reload(); |
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.
haha original solution, but please implement a real reset logic
|
|
||
|
|
||
|
|
||
| const showTipAmount = (event) => { |
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.
if this function is being triggered only when people's input changes what will happen if I just want to re-calcuate with different tip?
|
|
||
| const showTipAmount = (event) => { | ||
| const numOfPeople = event.target.value; | ||
| if (tipPrc === 0 || tipPrc === undefined) { |
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.
and what if tipPrc wasn't 0 and then the user wanted to go with custom tip?
| customTip = event.target.value; | ||
| } | ||
|
|
||
| const calculateBill = (billAmt, tipPrc) => { |
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.
can be implemented with one line
const getTotalBill = (billAmt, tipPrc) => illAmt * tipPrc
No description provided.