-
Couldn't load subscription status.
- Fork 10.5k
Passed all tests #22
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
base: master
Are you sure you want to change the base?
Passed all tests #22
Conversation
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.
Nice job B-)
index.js
Outdated
| if(destination > 42){ | ||
| return (destination - 42) * 264 | ||
| } | ||
| else{ | ||
| return (42 - destination) * 264 | ||
| } |
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.
Instead of duplicating the logic here, you can levage the the distanceFromHqInBlocks function:
| if(destination > 42){ | |
| return (destination - 42) * 264 | |
| } | |
| else{ | |
| return (42 - destination) * 264 | |
| } | |
| distanceFromHqInBlocks(destination) * 264 |
index.js
Outdated
| const distance = start > destination ? (start - destination) * 264 : (destination - start) * 264 | ||
| if(distance <= 400 ){ | ||
| return 0; | ||
| }else if(distance > 400 && distance < 2000){ | ||
| return .02 * (distance-400); | ||
| }else if(distance > 2500){ | ||
| return 'cannot travel that far' | ||
| }else if(distance > 2000){ | ||
| return 25; | ||
| } |
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.
| const distance = start > destination ? (start - destination) * 264 : (destination - start) * 264 | |
| if(distance <= 400 ){ | |
| return 0; | |
| }else if(distance > 400 && distance < 2000){ | |
| return .02 * (distance-400); | |
| }else if(distance > 2500){ | |
| return 'cannot travel that far' | |
| }else if(distance > 2000){ | |
| return 25; | |
| } | |
| const distance = start > destination ? (start - destination) * 264 : (destination - start) * 264 | |
| if(distance <= 400 ){ | |
| return 0; | |
| }else if(distance < 2000){ | |
| return .02 * (distance - 400); | |
| }else if(distance > 2500){ | |
| return 'cannot travel that far' | |
| }else if(distance > 2000){ | |
| return 25; | |
| } |
|
Cleaned up all functions and if blocks. |
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.
Nice work!
No description provided.