Skip to content

Commit

Permalink
Module exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
craigb28 committed Feb 12, 2024
1 parent c4bc46d commit fdfc8a4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/exercises/ScoreCalcs/averages.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ function averageForTest(testIndex,scores){
//TODO: Export all functions within an object.

module.exports = {
averageForStudent:averageForStudent,
averageForTest:averageForTest
averageForStudent,
averageForTest
};
2 changes: 1 addition & 1 deletion modules/exercises/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ function printTestScores(index,test,students,scores){
return;
}

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

//Candidate data:
let astronauts = ['Fox','Turtle','Cat','Hippo','Dog'];
Expand All @@ -19,7 +19,7 @@ for (let i = 0; i<prompts.length; i++){

if (response.toLowerCase()==='y'){
if (i===0){
printAll(astronauts, testTitles, scores);//Call 'printAll' here and pass in all necessary arguments.
printAll.printAll(astronauts, testTitles, scores);//Call 'printAll' here and pass in all necessary arguments.
}
else if (i===1){
for (let j = 0; j<testTitles.length; j++){
Expand Down
4 changes: 4 additions & 0 deletions modules/exporting-modules/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
// Import the modules exported from practiceExports.js below:

const practice = require('./practiceExports.js');

console.log(practice.isPalindrome('mom'));
6 changes: 6 additions & 0 deletions modules/exporting-modules/practiceExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ function randomArrayElement(arr){
let index = Math.floor(Math.random()*arr.length);
return arr[index];
}

module.exports = {
isPalindrome:isPalindrome,
evenOrOdd:evenOrOdd,
randomArrayElement:randomArrayElement
};

0 comments on commit fdfc8a4

Please sign in to comment.