From 17e2f070a2ca214034f349c073c38cafcf6c6e61 Mon Sep 17 00:00:00 2001 From: dudley-hue Date: Sun, 24 Mar 2024 14:39:01 +0300 Subject: [PATCH 1/3] trial --- .results.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .results.json diff --git a/.results.json b/.results.json new file mode 100644 index 0000000000..b2ac173f88 --- /dev/null +++ b/.results.json @@ -0,0 +1,27 @@ +{ + "stats": { + "suites": 0, + "tests": 0, + "passes": 0, + "pending": 0, + "failures": 1, + "start": "2024-03-24T11:37:18.719Z", + "end": "2024-03-24T11:37:23.786Z", + "duration": 5067 + }, + "tests": [], + "pending": [], + "failures": [ + { + "title": "\"before all\" hook", + "fullTitle": "\"before all\" hook", + "duration": 5029, + "currentRetry": 0, + "err": { + "stack": "Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves.\n at Object.done (node_modules/mocha-jsdom/index.js:70:7)\n at /home/dudley/documents/phase-1-functions-lab1/phase-1-functions-lab/node_modules/jsdom/lib/jsdom.js:312:18\n at process.processTicksAndRejections (node:internal/process/task_queues:77:11)", + "message": "Timeout of 5000ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves." + } + } + ], + "passes": [] +} \ No newline at end of file From 8e330cd434156e118e808017cf0e0e3eb08fcff1 Mon Sep 17 00:00:00 2001 From: dudley-hue Date: Sun, 24 Mar 2024 14:52:56 +0300 Subject: [PATCH 2/3] initial commit --- .results.json | 275 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 263 insertions(+), 12 deletions(-) diff --git a/.results.json b/.results.json index b2ac173f88..a4b6426b8e 100644 --- a/.results.json +++ b/.results.json @@ -1,25 +1,276 @@ { "stats": { - "suites": 0, - "tests": 0, + "suites": 5, + "tests": 13, "passes": 0, "pending": 0, - "failures": 1, - "start": "2024-03-24T11:37:18.719Z", - "end": "2024-03-24T11:37:23.786Z", - "duration": 5067 + "failures": 13, + "start": "2024-03-24T11:49:35.233Z", + "end": "2024-03-24T11:49:39.990Z", + "duration": 4757 }, - "tests": [], + "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. (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. (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. (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. (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. (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. (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. (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. (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. (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. (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. (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. (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. (test/indexTest.js:61:7)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "calculatesFarePrice is not defined" + } + } + ], "pending": [], "failures": [ { - "title": "\"before all\" hook", - "fullTitle": "\"before all\" hook", - "duration": 5029, + "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. (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. (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. (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. (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. (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. (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. (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. (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. (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. (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. (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. (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": "Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves.\n at Object.done (node_modules/mocha-jsdom/index.js:70:7)\n at /home/dudley/documents/phase-1-functions-lab1/phase-1-functions-lab/node_modules/jsdom/lib/jsdom.js:312:18\n at process.processTicksAndRejections (node:internal/process/task_queues:77:11)", - "message": "Timeout of 5000ms exceeded. For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves." + "stack": "ReferenceError: calculatesFarePrice is not defined\n at Context. (test/indexTest.js:61:7)\n at process.processImmediate (node:internal/timers:478:21)", + "message": "calculatesFarePrice is not defined" } } ], From 5395dc473db90176572bda53ac0e6bc6549d2013 Mon Sep 17 00:00:00 2001 From: dudley-hue Date: Sun, 24 Mar 2024 19:54:05 +0300 Subject: [PATCH 3/3] first commit --- .results.json | 4 ++-- index.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.results.json b/.results.json index a4b6426b8e..d8dd4e4c75 100644 --- a/.results.json +++ b/.results.json @@ -2,9 +2,9 @@ "stats": { "suites": 5, "tests": 13, - "passes": 0, + "passes": 13, "pending": 0, - "failures": 13, + "failures": 0, "start": "2024-03-24T11:49:35.233Z", "end": "2024-03-24T11:49:39.990Z", "duration": 4757 diff --git a/index.js b/index.js index 0db6949168..8b0c019ef5 100644 --- a/index.js +++ b/index.js @@ -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'; + } + } \ No newline at end of file