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
11 changes: 11 additions & 0 deletions data/assignments.js
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 28 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/**

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 { assignments } = require('./data/assignments')
/*console.log({assignments})


/**

Expand All @@ -16,28 +21,49 @@
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

3) Loop through the data using a for loop. Just console.log within the loop to show each item within the array

*/



/**

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)

/**

Expand Down