diff --git a/index.js b/index.js index 0db6949168..4c886919d4 100644 --- a/index.js +++ b/index.js @@ -1 +1,25 @@ -// Code your solution in this file! +function distanceFromHqInBlocks(street) { + return Math.abs(42 - street); +} + +function distanceFromHqInFeet(feetToHQ) { + return distanceFromHqInBlocks(feetToHQ) * 264; +} + +function distanceTravelledInFeet(startingBlock, endingBlock) { + return Math.abs(startingBlock - endingBlock) * 264; +} + +function calculatesFarePrice(start, destination){ + const distance = Math.abs(start-destination)*264; + + if (distance <= 400){ + return 0; + } else if (distance > 400 && distance <= 2000){ + return (distance - 400)* .02; + } else if (distance > 2000 && distance <=2500){ + return 25; + } else { + return 'cannot travel that far'; + } +} \ No newline at end of file