Skip to content

Commit

Permalink
Modules - Practice and exercises completed
Browse files Browse the repository at this point in the history
  • Loading branch information
KayalvizhiRajendran committed Jun 13, 2024
1 parent ee47938 commit e740564
Show file tree
Hide file tree
Showing 15 changed files with 3,789 additions and 7 deletions.
5 changes: 5 additions & 0 deletions modules/exercises/ScoreCalcs/averages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ function averageForTest(testIndex,scores){
}

//TODO: Export all functions within an object.

module.exports = {
averageForStudent: averageForStudent,
averageForTest: averageForTest
}
4 changes: 4 additions & 0 deletions modules/exercises/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ function printTestScores(index,test,students,scores){
}
return;
}

module.exports = {
printAll: printAll
}
15 changes: 8 additions & 7 deletions modules/exercises/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//Import modules:
const input = //Import readline-sync.
const averages = //Import functions from averages.js.
const printAll = //Import function from display.js.
const randomSelect = //Import function from randomSelect.js.
const input = require('readline-sync'); //Import readline-sync.
const averages = require('./ScoreCalcs/averages.js');//Import functions from averages.js.
const printAll = require('./display.js');//Import function from display.js.
const randomSelect = require('./randomSelect.js');//Import function from randomSelect.js.

//Candidate data:
let astronauts = ['Fox','Turtle','Cat','Hippo','Dog'];
Expand All @@ -19,18 +19,19 @@ for (let i = 0; i<prompts.length; i++){
if (response.toLowerCase()==='y'){
if (i===0){
//Call 'printAll' here and pass in all necessary arguments.
printAll.printAll(astronauts, testTitles, scores);
} else if (i===1){
for (let j = 0; j<testTitles.length; j++){
let avg = //Call 'averageForTest' here. Pass in j and scores as arguments.
let avg = averages.averageForTest(j,scores);//Call 'averageForTest' here. Pass in j and scores as arguments.
console.log(`${testTitles[j]} test average = ${avg}%.`);
}
} else if (i===2){
for (let j = 0; j<astronauts.length; j++){
let avg = //Call 'averageForStudent' here. Pass in j and scores as arguments.
let avg = averages.averageForStudent(j,scores);//Call 'averageForStudent' here. Pass in j and scores as arguments.
console.log(`${astronauts[j]}'s test average = ${avg}%.`);
}
} else {
let walker = //Call 'randomSelect' to pick a spacewalker from the astronauts array.
let walker = randomSelect.randomFromArray(astronauts);//Call 'randomSelect' to pick a spacewalker from the astronauts array.
console.log(`${walker} is the next spacewalker.`);
}
} else {
Expand Down
16 changes: 16 additions & 0 deletions modules/exercises/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions modules/exercises/node_modules/readline-sync/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions modules/exercises/node_modules/readline-sync/README-Deprecated.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e740564

Please sign in to comment.