Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
278 changes: 278 additions & 0 deletions .results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
{
"stats": {
"suites": 5,
"tests": 13,
"passes": 13,
"pending": 0,
"failures": 0,
"start": "2024-03-24T11:49:35.233Z",
"end": "2024-03-24T11:49:39.990Z",
"duration": 4757
},
"tests": [
{
"title": "returns a distance in blocks",
"fullTitle": "index.js distanceFromHqInBlocks() returns a distance in blocks",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInBlocks is not defined\n at Context.<anonymous> (test/indexTest.js:6:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInBlocks is not defined"
}
},
{
"title": "returns a distance in blocks",
"fullTitle": "index.js distanceFromHqInBlocks() returns a distance in blocks",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInBlocks is not defined\n at Context.<anonymous> (test/indexTest.js:10:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInBlocks is not defined"
}
},
{
"title": "calculates distances below 42nd street",
"fullTitle": "index.js distanceFromHqInBlocks() calculates distances below 42nd street",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInBlocks is not defined\n at Context.<anonymous> (test/indexTest.js:14:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInBlocks is not defined"
}
},
{
"title": "returns a distance in feet",
"fullTitle": "index.js distanceFromHqInFeet() returns a distance in feet",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:20:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInFeet is not defined"
}
},
{
"title": "returns a distance in feet",
"fullTitle": "index.js distanceFromHqInFeet() returns a distance in feet",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:24:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInFeet is not defined"
}
},
{
"title": "calculates distances below 42nd street",
"fullTitle": "index.js distanceFromHqInFeet() calculates distances below 42nd street",
"duration": 2,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:28:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInFeet is not defined"
}
},
{
"title": "returns the distance travelled in feet",
"fullTitle": "index.js distanceTravelledInFeet() returns the distance travelled in feet",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceTravelledInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:34:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceTravelledInFeet is not defined"
}
},
{
"title": "returns a distance in feet",
"fullTitle": "index.js distanceTravelledInFeet() returns a distance in feet",
"duration": 3,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceTravelledInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:38:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceTravelledInFeet is not defined"
}
},
{
"title": "returns distance when destination is below distance",
"fullTitle": "index.js distanceTravelledInFeet() returns distance when destination is below distance",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceTravelledInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:42:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceTravelledInFeet is not defined"
}
},
{
"title": "gives customers a free sample",
"fullTitle": "index.js calculatesFarePrice(start, destination) gives customers a free sample",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: calculatesFarePrice is not defined\n at Context.<anonymous> (test/indexTest.js:48:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "calculatesFarePrice is not defined"
}
},
{
"title": "charges 2 cents per foot when total feet travelled is between 400 and 2000 (remember the first 400 feet are free!)",
"fullTitle": "index.js calculatesFarePrice(start, destination) charges 2 cents per foot when total feet travelled is between 400 and 2000 (remember the first 400 feet are free!)",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: calculatesFarePrice is not defined\n at Context.<anonymous> (test/indexTest.js:53:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "calculatesFarePrice is not defined"
}
},
{
"title": "charges 25 dollars for a distance over 2000 feet",
"fullTitle": "index.js calculatesFarePrice(start, destination) charges 25 dollars for a distance over 2000 feet",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: calculatesFarePrice is not defined\n at Context.<anonymous> (test/indexTest.js:57:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "calculatesFarePrice is not defined"
}
},
{
"title": "does not allow rides over 2500 feet",
"fullTitle": "index.js calculatesFarePrice(start, destination) does not allow rides over 2500 feet",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: calculatesFarePrice is not defined\n at Context.<anonymous> (test/indexTest.js:61:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "calculatesFarePrice is not defined"
}
}
],
"pending": [],
"failures": [
{
"title": "returns a distance in blocks",
"fullTitle": "index.js distanceFromHqInBlocks() returns a distance in blocks",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInBlocks is not defined\n at Context.<anonymous> (test/indexTest.js:6:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInBlocks is not defined"
}
},
{
"title": "returns a distance in blocks",
"fullTitle": "index.js distanceFromHqInBlocks() returns a distance in blocks",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInBlocks is not defined\n at Context.<anonymous> (test/indexTest.js:10:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInBlocks is not defined"
}
},
{
"title": "calculates distances below 42nd street",
"fullTitle": "index.js distanceFromHqInBlocks() calculates distances below 42nd street",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInBlocks is not defined\n at Context.<anonymous> (test/indexTest.js:14:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInBlocks is not defined"
}
},
{
"title": "returns a distance in feet",
"fullTitle": "index.js distanceFromHqInFeet() returns a distance in feet",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:20:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInFeet is not defined"
}
},
{
"title": "returns a distance in feet",
"fullTitle": "index.js distanceFromHqInFeet() returns a distance in feet",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:24:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInFeet is not defined"
}
},
{
"title": "calculates distances below 42nd street",
"fullTitle": "index.js distanceFromHqInFeet() calculates distances below 42nd street",
"duration": 2,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceFromHqInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:28:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceFromHqInFeet is not defined"
}
},
{
"title": "returns the distance travelled in feet",
"fullTitle": "index.js distanceTravelledInFeet() returns the distance travelled in feet",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceTravelledInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:34:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceTravelledInFeet is not defined"
}
},
{
"title": "returns a distance in feet",
"fullTitle": "index.js distanceTravelledInFeet() returns a distance in feet",
"duration": 3,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceTravelledInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:38:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceTravelledInFeet is not defined"
}
},
{
"title": "returns distance when destination is below distance",
"fullTitle": "index.js distanceTravelledInFeet() returns distance when destination is below distance",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: distanceTravelledInFeet is not defined\n at Context.<anonymous> (test/indexTest.js:42:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "distanceTravelledInFeet is not defined"
}
},
{
"title": "gives customers a free sample",
"fullTitle": "index.js calculatesFarePrice(start, destination) gives customers a free sample",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: calculatesFarePrice is not defined\n at Context.<anonymous> (test/indexTest.js:48:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "calculatesFarePrice is not defined"
}
},
{
"title": "charges 2 cents per foot when total feet travelled is between 400 and 2000 (remember the first 400 feet are free!)",
"fullTitle": "index.js calculatesFarePrice(start, destination) charges 2 cents per foot when total feet travelled is between 400 and 2000 (remember the first 400 feet are free!)",
"duration": 1,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: calculatesFarePrice is not defined\n at Context.<anonymous> (test/indexTest.js:53:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "calculatesFarePrice is not defined"
}
},
{
"title": "charges 25 dollars for a distance over 2000 feet",
"fullTitle": "index.js calculatesFarePrice(start, destination) charges 25 dollars for a distance over 2000 feet",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: calculatesFarePrice is not defined\n at Context.<anonymous> (test/indexTest.js:57:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "calculatesFarePrice is not defined"
}
},
{
"title": "does not allow rides over 2500 feet",
"fullTitle": "index.js calculatesFarePrice(start, destination) does not allow rides over 2500 feet",
"duration": 0,
"currentRetry": 0,
"err": {
"stack": "ReferenceError: calculatesFarePrice is not defined\n at Context.<anonymous> (test/indexTest.js:61:7)\n at process.processImmediate (node:internal/timers:478:21)",
"message": "calculatesFarePrice is not defined"
}
}
],
"passes": []
}
33 changes: 33 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
//Code your solution in this file!
functions // Code your solution in this file!


// Code your solution in this file!

function distanceFromHqInBlocks(block){
return Math.abs(block-42)
}

function distanceFromHqInFeet(feet){
return Math.abs((feet-42) * 264)
}

function distanceTravelledInFeet(start,destination){
const lengthInBlock = Math.abs(start - destination);
//264 = the value of feet
return lengthInBlock * 264;
}

function calculatesFarePrice(start,destination){

const distanceTravelled = distanceTravelledInFeet(start,destination)

if(distanceTravelled <= 400){
return 0;
}else if(distanceTravelled > 400 && distanceTravelled <= 2000){
return 2 *(distanceTravelled - 400)/100;
}else if(distanceTravelled > 2000 && distanceTravelled <= 2500){
return 25;
}else if(distanceTravelled > 2500){
return 'cannot travel that far';
}
}