-
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
Complete Lab #26
base: master
Are you sure you want to change the base?
Complete Lab #26
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 +1,38 @@ | ||||||||||||||||||||||||
// Code your solution in this file! | ||||||||||||||||||||||||
function distanceFromHqInBlocks(num1){ | ||||||||||||||||||||||||
if (num1 > 42) { | ||||||||||||||||||||||||
return num1 - 42; | ||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||
return 42 - num1; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
}; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
function distanceFromHqInFeet(num) { | ||||||||||||||||||||||||
let feet = distanceFromHqInBlocks(num); | ||||||||||||||||||||||||
return feet * 264; | ||||||||||||||||||||||||
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.
Suggested change
|
||||||||||||||||||||||||
}; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
function distanceTravelledInFeet(start, destination) { | ||||||||||||||||||||||||
let block; | ||||||||||||||||||||||||
if (start > destination) { | ||||||||||||||||||||||||
block = start - destination; | ||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||
block = destination - start; | ||||||||||||||||||||||||
} return block * 264; | ||||||||||||||||||||||||
Comment on lines
+16
to
+21
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. Since you're not doing anything with the block, you don't need to assign it to a constant.
Suggested change
|
||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
function calculatesFarePrice(start, destination) { | ||||||||||||||||||||||||
let fare = distanceTravelledInFeet(start, destination); | ||||||||||||||||||||||||
let distanceAfterFreeRide = fare - 400; | ||||||||||||||||||||||||
if (distanceAfterFreeRide <= 0) { | ||||||||||||||||||||||||
return 0; | ||||||||||||||||||||||||
} else if (distanceAfterFreeRide < 1600) { | ||||||||||||||||||||||||
return distanceAfterFreeRide * 0.02; | ||||||||||||||||||||||||
} else if (distanceAfterFreeRide >= 1600 && distanceAfterFreeRide <= 2100) { | ||||||||||||||||||||||||
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.
Suggested change
|
||||||||||||||||||||||||
return 25; | ||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||
return 'cannot travel that far'; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
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.
What do you think a better name for the argument
num1
could be?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.
block or blockNum?
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.
Either would be good! I like
blockNumber
or evenstartingBlockNumber
since it's most descriptive.