Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete Lab #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
37 changes: 37 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
// Code your solution in this file!
function distanceFromHqInBlocks(num1){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think a better name for the argument num1 could be?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block or blockNum?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either would be good! I like blockNumber or even startingBlockNumber since it's most descriptive.

if (num1 > 42) {
return num1 - 42;
} else {
return 42 - num1;
}
};

function distanceFromHqInFeet(num) {
let feet = distanceFromHqInBlocks(num);
return feet * 264;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return feet * 264;
return feet * 264;

};

function distanceTravelledInFeet(start, destination) {
let block;
if (start > destination) {
block = start - destination;
} else {
block = destination - start;
} return block * 264;
Comment on lines +16 to +21

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're not doing anything with the block, you don't need to assign it to a constant.

Suggested change
let block;
if (start > destination) {
block = start - destination;
} else {
block = destination - start;
} return block * 264;
if (start > destination) {
return start - destination;
} else {
return destination - start;
}

}

function calculatesFarePrice(start, destination) {
let fare = distanceTravelledInFeet(start, destination);
let distanceAfterFreeRide = fare - 400;
if (distanceAfterFreeRide <= 0) {
return 0;
} else if (distanceAfterFreeRide < 1600) {
return distanceAfterFreeRide * 0.02;
} else if (distanceAfterFreeRide >= 1600 && distanceAfterFreeRide <= 2100) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (distanceAfterFreeRide >= 1600 && distanceAfterFreeRide <= 2100) {
} else if (distanceAfterFreeRide <= 2100) {

return 25;
} else {
return 'cannot travel that far';
}
}