-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Added Greeting Functions #17
base: master
Are you sure you want to change the base?
Added Greeting Functions #17
Conversation
let scuberGreeting | ||
if(rideDistance <= 400){ | ||
scuberGreeting = 'This one is on me!' | ||
}else if(rideDistance > 400 && rideDistance < 2000){ |
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.
You can exclude rideDistance > 400 &&
since it's already covered by the first part of the conditional.
}else if(rideDistance > 400 && rideDistance < 2000){ | |
}else if(rideDistance < 2000){ |
function scuberGreetingForFeet(rideDistance){ | ||
let scuberGreeting | ||
if(rideDistance <= 400){ | ||
scuberGreeting = 'This one is on me!' | ||
}else if(rideDistance > 400 && rideDistance < 2000){ | ||
scuberGreeting ='That will be twenty bucks.' | ||
}else if(rideDistance < 2500 && rideDistance > 2000){ | ||
scuberGreeting = 'I will gladly take your thirty bucks.' | ||
}else if (rideDistance > 2500){ | ||
scuberGreeting = 'No can do.' | ||
} | ||
return scuberGreeting |
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.
I know it seems trivial, but consistent spacing that follows the "standards" is important for readability.
function scuberGreetingForFeet(rideDistance){ | |
let scuberGreeting | |
if(rideDistance <= 400){ | |
scuberGreeting = 'This one is on me!' | |
}else if(rideDistance > 400 && rideDistance < 2000){ | |
scuberGreeting ='That will be twenty bucks.' | |
}else if(rideDistance < 2500 && rideDistance > 2000){ | |
scuberGreeting = 'I will gladly take your thirty bucks.' | |
}else if (rideDistance > 2500){ | |
scuberGreeting = 'No can do.' | |
} | |
return scuberGreeting | |
function scuberGreetingForFeet(rideDistance){ | |
let scuberGreeting | |
if (rideDistance <= 400) { | |
scuberGreeting = 'This one is on me!' | |
} else if (rideDistance > 400 && rideDistance < 2000) { | |
scuberGreeting ='That will be twenty bucks.' | |
} else if (rideDistance < 2500 && rideDistance > 2000) { | |
scuberGreeting = 'I will gladly take your thirty bucks.' | |
} else if (rideDistance > 2500) { | |
scuberGreeting = 'No can do.' | |
} | |
return scuberGreeting |
let tipGreeting; | ||
switch(tip){ | ||
case 'generous' : | ||
tipGreeting = 'Thank you so much.' | ||
break; | ||
case 'not as generous' : | ||
tipGreeting = 'Thank you.' | ||
break; | ||
default: | ||
tipGreeting = 'Bye.' | ||
} | ||
return tipGreeting | ||
} |
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.
Here's an easy way to clean this up:
function switchOnCharmFromTip(tip){
switch(tip){
case 'generous':
return 'Thank you so much.'
case 'not as generous':
return 'Thank you.'
default:
return 'Bye.'
}
scuberGreeting ='That will be twenty bucks.' | ||
}else if(rideDistance < 2500 && rideDistance > 2000){ | ||
scuberGreeting = 'I will gladly take your thirty bucks.' | ||
}else if (rideDistance > 2500){ |
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.
Same idea here... this isn't need since it's already covered.
}else if (rideDistance > 2500){ | |
} else { |
No description provided.