Skip to content

Commit 5fcfd91

Browse files
Jim FloresJim Flores
authored andcommitted
Added print statements to parts 3 - 5.
1 parent ee11f84 commit 5fcfd91

File tree

6 files changed

+21
-11
lines changed

6 files changed

+21
-11
lines changed

exercises/part3.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ var speedMph = 17500;
55
var kilometersToMars = 225000000;
66
var kilometersToTheMoon = 384400;
77
var milesPerKilometer = 0.621;
8-
// Part 3 - Define the 'getDaysToLocation' function here:
8+
// Code the "getDaysToLocation" function here:
99
function getDaysToLocation(kilometersAway) {
1010
var milesAway = kilometersAway * milesPerKilometer;
1111
var hours = milesAway / speedMph;
1212
return hours / 24;
1313
}
14-
// Call the function and print the output here:
14+
// Call the function and print the outputs for the Mars trip and the moon trip:
1515
console.log(spacecraftName + " would take " + getDaysToLocation(kilometersToMars) + " to get to Mars.");
16+
console.log(spacecraftName + " would take " + getDaysToLocation(kilometersToTheMoon) + " to get to the Moon.");

exercises/part3.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ let kilometersToMars: number = 225000000;
77
let kilometersToTheMoon: number = 384400;
88
let milesPerKilometer: number = 0.621;
99

10-
// Part 3 - Define the 'getDaysToLocation' function here:
10+
// Code the "getDaysToLocation" function here:
1111
function getDaysToLocation(kilometersAway: number): number {
1212
let milesAway: number = kilometersAway * milesPerKilometer;
1313
let hours: number = milesAway / speedMph;
1414
return hours / 24;
1515
}
1616

17-
// Call the function and print the output here:
18-
console.log(`${spacecraftName} would take ${getDaysToLocation(kilometersToMars)} to get to Mars.`);
17+
// Call the function and print the outputs for the Mars trip and the moon trip:
18+
console.log(`${spacecraftName} would take ${getDaysToLocation(kilometersToMars)} to get to Mars.`);
19+
console.log(`${spacecraftName} would take ${getDaysToLocation(kilometersToTheMoon)} to get to the Moon.`);

exercises/part4.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var kilometersToMars = 225000000;
22
var kilometersToTheMoon = 384400;
3-
// Part 4 - Define your Spacecraft class here:
3+
// Define your Spacecraft class here:
44
var Spacecraft = /** @class */ (function () {
55
function Spacecraft(name, speedMph) {
66
this.milesPerKilometer = 0.621;
@@ -14,5 +14,8 @@ var Spacecraft = /** @class */ (function () {
1414
};
1515
return Spacecraft;
1616
}());
17+
// Create an instance of the class here:
1718
var spaceShuttle = new Spacecraft('Discovery', 17500);
19+
// Print two outputs - one for the trip to Mars and one for the trip to the moon.
1820
console.log(spaceShuttle.name + " would take " + spaceShuttle.getDaysToLocation(kilometersToMars) + " days to get to Mars.");
21+
console.log(spaceShuttle.name + " would take " + spaceShuttle.getDaysToLocation(kilometersToTheMoon) + " days to get to Mars.");

exercises/part4.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let kilometersToMars: number = 225000000;
22
let kilometersToTheMoon: number = 384400;
33

4-
// Part 4 - Define your Spacecraft class here:
4+
// Define your Spacecraft class here:
55
class Spacecraft {
66
milesPerKilometer: number = 0.621;
77
name: string;
@@ -20,6 +20,9 @@ class Spacecraft {
2020

2121
}
2222

23+
// Create an instance of the class here:
2324
let spaceShuttle = new Spacecraft('Discovery', 17500);
2425

26+
// Print two outputs - one for the trip to Mars and one for the trip to the moon.
2527
console.log(`${spaceShuttle.name} would take ${spaceShuttle.getDaysToLocation(kilometersToMars)} days to get to Mars.`);
28+
console.log(`${spaceShuttle.name} would take ${spaceShuttle.getDaysToLocation(kilometersToTheMoon)} days to get to Mars.`);

exercises/part5.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"use strict";
22
exports.__esModule = true;
3-
// Part 5 - Add your import statement to line 2:
3+
// Add your import statement to line 2:
44
var SpaceLocation_1 = require("./SpaceLocation");
55
var kilometersToMars = 225000000;
66
var kilometersToTheMoon = 384400;
7-
// Part 4 - Define your Spacecraft class here:
87
var Spacecraft = /** @class */ (function () {
98
function Spacecraft(name, speedMph) {
109
this.milesPerKilometer = 0.621;
@@ -21,6 +20,8 @@ var Spacecraft = /** @class */ (function () {
2120
};
2221
return Spacecraft;
2322
}());
23+
// Create an instance of Spacecraft:
2424
var spaceShuttle = new Spacecraft('Discovery', 17500);
25+
// Print the output for the trips to Mars and the moon:
2526
spaceShuttle.printDaysToLocation(new SpaceLocation_1.SpaceLocation('Mars', kilometersToMars));
2627
spaceShuttle.printDaysToLocation(new SpaceLocation_1.SpaceLocation('the Moon', kilometersToTheMoon));

exercises/part5.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// Part 5 - Add your import statement to line 2:
1+
// Add your import statement to line 2:
22
import { SpaceLocation } from './SpaceLocation';
33

44
let kilometersToMars: number = 225000000;
55
let kilometersToTheMoon: number = 384400;
66

7-
// Part 4 - Define your Spacecraft class here:
87
class Spacecraft {
98
milesPerKilometer: number = 0.621;
109
name: string;
@@ -26,7 +25,9 @@ class Spacecraft {
2625
}
2726
}
2827

28+
// Create an instance of Spacecraft:
2929
let spaceShuttle = new Spacecraft('Discovery', 17500);
3030

31+
// Print the output for the trips to Mars and the moon:
3132
spaceShuttle.printDaysToLocation(new SpaceLocation('Mars', kilometersToMars));
3233
spaceShuttle.printDaysToLocation(new SpaceLocation('the Moon', kilometersToTheMoon));

0 commit comments

Comments
 (0)