In averages.js
, add code to export all of the functions within an
object.
1module.exports = {
2 averageForStudent: averageForStudent,
3 averageForTest: averageForTest
4};
Add code to complete the randomFromArray
function. It should take an
array as an argument and then return a randomly selected element from that array.
1function randomFromArray(arr){
2 let index = Math.floor(Math.random()*arr.length);
3 return arr[index];
4}
Assign readline-sync
to the input
variable.
const input = require('readline-sync');
Assign the printAll
function from display.js
to the printAll
variable.
const printAll = require('./display.js');
Line 21 - Call printAll
to display all of the tests and student
scores. Be sure to pass in the correct arguments.
21printAll(astronauts, testTitles, scores);
Line 29 - Call averageForStudent
(with the proper arguments) to print
each astronaut's average score.
29let avg = averages.averageForStudent(j, scores);