Skip to content

Commit 094cfef

Browse files
committed
add imports
1 parent d135454 commit 094cfef

1 file changed

Lines changed: 29 additions & 18 deletions

File tree

modules/exercises/index.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
11
//Import modules:
2-
const input = //Import readline-sync.
3-
const averages = //Import functions from averages.js.
4-
const printAll = //Import function from display.js.
5-
const randomSelect = //Import function from randomSelect.js.
2+
const input = require(readline - sync);
3+
const averages = require(modules / exercises / ScoreCalcs / averages.js);
4+
const printAll = require(display.js);
5+
const randomSelect = require(randomSelect.js);
66

77
//Candidate data:
8-
let astronauts = ['Fox','Turtle','Cat','Hippo','Dog'];
8+
let astronauts = ["Fox", "Turtle", "Cat", "Hippo", "Dog"];
99

10-
const testTitles = ['Math','Fitness','Coding','Nav','Communication'];
10+
const testTitles = ["Math", "Fitness", "Coding", "Nav", "Communication"];
1111

12-
let scores = [[95, 86, 83, 81, 76],[79, 71, 79, 87, 72],[94, 87, 87, 83, 82],[99, 77, 91, 79, 80],[96, 95, 99, 82, 70]];
12+
let scores = [
13+
[95, 86, 83, 81, 76],
14+
[79, 71, 79, 87, 72],
15+
[94, 87, 87, 83, 82],
16+
[99, 77, 91, 79, 80],
17+
[96, 95, 99, 82, 70],
18+
];
1319

1420
//User interface:
15-
let prompts = ['display all scores', 'average the scores for each test', 'average the scores for each astronaut','select the next spacewalker'];
21+
let prompts = [
22+
"display all scores",
23+
"average the scores for each test",
24+
"average the scores for each astronaut",
25+
"select the next spacewalker",
26+
];
1627

17-
for (let i = 0; i<prompts.length; i++){
28+
for (let i = 0; i < prompts.length; i++) {
1829
let response = input.question(`Would you like to ${prompts[i]}? Y/N: `);
19-
if (response.toLowerCase()==='y'){
20-
if (i===0){
30+
if (response.toLowerCase() === "y") {
31+
if (i === 0) {
2132
//Call 'printAll' here and pass in all necessary arguments.
22-
} else if (i===1){
23-
for (let j = 0; j<testTitles.length; j++){
33+
} else if (i === 1) {
34+
for (let j = 0; j < testTitles.length; j++) {
2435
let avg = //Call 'averageForTest' here. Pass in j and scores as arguments.
25-
console.log(`${testTitles[j]} test average = ${avg}%.`);
36+
console.log(`${testTitles[j]} test average = ${avg}%.`);
2637
}
27-
} else if (i===2){
28-
for (let j = 0; j<astronauts.length; j++){
38+
} else if (i === 2) {
39+
for (let j = 0; j < astronauts.length; j++) {
2940
let avg = //Call 'averageForStudent' here. Pass in j and scores as arguments.
30-
console.log(`${astronauts[j]}'s test average = ${avg}%.`);
41+
console.log(`${astronauts[j]}'s test average = ${avg}%.`);
3142
}
3243
} else {
3344
let walker = //Call 'randomSelect' to pick a spacewalker from the astronauts array.
34-
console.log(`${walker} is the next spacewalker.`);
45+
console.log(`${walker} is the next spacewalker.`);
3546
}
3647
} else {
3748
console.log("Option skipped.");

0 commit comments

Comments
 (0)