-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,11 +1,33 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
function scuberGreetingForFeet(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||
// Write your code here! | ||||||||||||||||||||||||||||||||||||||||||||||||||
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){ | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same idea here... this isn't need since it's already covered.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
scuberGreeting = 'No can do.' | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
return scuberGreeting | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+1
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
function ternaryCheckCity(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||
// Write your code here! | ||||||||||||||||||||||||||||||||||||||||||||||||||
function ternaryCheckCity(city){ | ||||||||||||||||||||||||||||||||||||||||||||||||||
let cityGreeting = city === 'NYC' ? 'Ok, sounds good.' : 'No go.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
return cityGreeting | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
function switchOnCharmFromTip(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||
// Write your code here! | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
function switchOnCharmFromTip(tip){ | ||||||||||||||||||||||||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+20
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.'
} |
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.