Skip to content

Conversation

@roiyraz88
Copy link

No description provided.

Copy link

@danielmargolin danielmargolin left a 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

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) {

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

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

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();

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) => {

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) {

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) => {

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

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