Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = grades
29 changes: 25 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,40 @@
- Use 2 distinct student names

*/
let grades =[{assignmentName: "week01", studentName: "James", score: 10},
{assignmentName: "week02", studentName: "paul", score: 20},
{assignmentName: "week03", studentName: "James", score: 30}
, {assignmentName: "week04", studentName: "Mathieu", score:40},
{assignmentName: "week05", studentName: "paul", score: 50}]

//console.log({grade})

//let { grades } = require(`./data/grades`)

/**

/**
co
Looping using your preferred looping syntax and updating a shared variable

2) Loop through the grades data using a for loop.
Update `gradeTotal` so it increases value for each item in the array

*/
const gradeTotal = 0

let gradeTotal = 0

for (let i= 0; i < grades.length; i++ ) {


gradeTotal += grades[i].score
}
console.log({gradeTotal})
gradeTotal = grades.reduce( (total, grade)=> {
console.log(total, grade)
return total
}, 0)
/**
*
*

Using reduce

Expand Down