diff --git a/data/assignments.js b/data/assignments.js index e69de29..a891740 100644 --- a/data/assignments.js +++ b/data/assignments.js @@ -0,0 +1,11 @@ +const assignments = [ + {name: 'firstAssignment', completed: true}, + {name: 'secondAssignment', completed: false}, + {name: 'fourthAssignment', completed: false}, + {name: 'fifthAssignment', completed: true}, + {name: 'thirdAssignment', completed: true} +] + +module.exports = { + assignments +} \ No newline at end of file diff --git a/index.js b/index.js index a4899ce..3d02be9 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,8 @@ /** We will push to github all along the way so we track our week and keep a log + a) code in git, start working. First step: 'git checkout -b answer' + Declaring an Array with Objects @@ -8,6 +10,9 @@ */ +const { assignments } = require('./data/assignments') +/*console.log({assignments}) + /** @@ -16,13 +21,24 @@ 2a) Great work! Now move that array initialization out into its own file. See ./data/assignments.js where you will initialize the data in place of inline in this function + + 2b) "Import" that data into this file in place of the inline code you had in step 1 */ +/*for (let i = 0; i < assignments.length; i = i + 1) { + const assignment = assignments [i] + console.log({ assignment }) +} + + +//assignments.forEach((assignment) => { }) + +/* + -/** Looping and using references to arrays a given positions @@ -30,14 +46,24 @@ */ + + /** Looping and Assignment - 4) Declare a new array named `allAssignments`. Loop through the `assignments` array data using a for loop and assign each item from `assignments` to the new `allAssignments` array + 4) Declare a new array named `allAssignments`. Loop through the `assignments` + array data using a for loop and assign each item from `assignments` to the new + `allAssignments` array */ +const allAssignments = [] +for (let i = 0; i < assignments.length; i = i + 1) { + allAssignments[i] = assignments [i] +} + +console.log(allAssignments) /**