forked from learn-co-curriculum/phase-1-functions-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (24 loc) · 946 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Code your solution in this file!
const distanceFromHqInBlocks = distant => distant > 42 ? distant - 42 : 42 - distant
const distanceFromHqInFeet = feet => distanceFromHqInBlocks(feet) * 264
const distanceTravelledInFeet = (start, destination) => {
let travelled = destination - start;
return start && destination > 42 ? travelled * 264 : Math.abs(travelled * 264)
}
const calculatesFarePrice = (start, destination) => {
let travelled = distanceTravelledInFeet(start, destination);
let surChargeCents = travelled - 400;
// let surChargeDollars = travelled - 2000;
if (travelled < 400) {
return 0;
} else if (travelled < 2000) {
return surChargeCents * .02;
} else if (travelled > 2000 && travelled < 2500) {
return 25;
} else {
return 'cannot travel that far';
}
}
// console.log(distanceFromHqInFeet(34));
// console.log(distanceTravelledInFeet(50, 60));
// console.log (calculatesFarePrice(34,24));