Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions index.js
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){

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.

Suggested change
}else if(rideDistance > 400 && rideDistance < 2000){
}else if(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){

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.

Suggested change
}else if (rideDistance > 2500){
} else {

scuberGreeting = 'No can do.'
}
return scuberGreeting
Comment on lines +1 to +12

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.

Suggested change
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

}

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

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.'
  }