diff --git a/index.js b/index.js index 0db6949168..03d179ff25 100644 --- a/index.js +++ b/index.js @@ -1 +1,24 @@ -// Code your solution in this file! +function distanceFromHqInBlocks(destination){ + return Math.abs(destination - 42) +} + +function distanceFromHqInFeet(destination){ + return Math.abs(distanceFromHqInBlocks(destination) * 264) +} + +function distanceTravelledInFeet(start, destination){ + return Math.abs((start - destination) * 264) +} + +function calculatesFarePrice(start, destination){ + const distance = distanceTravelledInFeet(start, destination) + if(distance <= 400 ){ + return 0; + }else if(distance < 2000){ + return .02 * (distance - 400); + }else if(distance < 2500){ + return 25; + }else{ + return 'cannot travel that far' + } +}