From 8ebffa36d5965086d7ec778da86617b987c7c38d Mon Sep 17 00:00:00 2001 From: Prasanna Date: Wed, 22 Jul 2020 19:22:44 -0400 Subject: [PATCH 1/3] Response to Declaring Arrays --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index a4899ce..b69ee7e 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,23 @@ /** 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 1) Declare and initialize an array of `assignments` with `name` and `completed` properties. Name the array `assignments`. `completed` will have boolean values. */ +const projects = [ + {name: firstAssignment, completed: true}, + {name: secondAssignment, completed: false}, + {name: fourthAssignment, completed: false}, + {name: fifthAssignment, completed: true}, + {name: thirdAssignment, completed: true} + + +] /** From 83e0cec4c46b818763e9c93cbacc3600e350bedf Mon Sep 17 00:00:00 2001 From: Prasanna Date: Wed, 22 Jul 2020 20:09:37 -0400 Subject: [PATCH 2/3] Responses --- data/assignments.js | 11 +++++++++++ index.js | 12 ++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) 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 b69ee7e..74cc622 100644 --- a/index.js +++ b/index.js @@ -9,15 +9,9 @@ 1) Declare and initialize an array of `assignments` with `name` and `completed` properties. Name the array `assignments`. `completed` will have boolean values. */ -const projects = [ - {name: firstAssignment, completed: true}, - {name: secondAssignment, completed: false}, - {name: fourthAssignment, completed: false}, - {name: fifthAssignment, completed: true}, - {name: thirdAssignment, completed: true} - -] +const { assignments } = require('./data/assignments') +console.log({assignments}) /** @@ -27,6 +21,8 @@ const projects = [ 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 From 0c40e758616053e183c687796c9df40543c0d52d Mon Sep 17 00:00:00 2001 From: Prasanna Date: Wed, 22 Jul 2020 21:44:19 -0400 Subject: [PATCH 3/3] Responses --- index.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 74cc622..3d02be9 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,7 @@ */ const { assignments } = require('./data/assignments') -console.log({assignments}) +/*console.log({assignments}) /** @@ -28,8 +28,17 @@ console.log({assignments}) */ +/*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 @@ -37,14 +46,24 @@ console.log({assignments}) */ + + /** 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) /**