find – returns the first item that matches what you are looking for (kind of like a filter, but just grabs the first one it finds)
findIndex tells us the index of the first item in an array that matches a certain condition *remember count starts at 0]
Object.assign – used to copy the properties from one object onto another
.Splice – used to delete an item from an array, so long as you know what index it lives at. The first argument is the index the item starts at, the second is the # of items you want to delete
.unshift adds an item to the left side of an array
push adds an item to the right side of an array
Connecting front end to the back end
The code below sends the information to our server from the website. Note that the "stringify" method turns whatever we are sending through the web into a string (necessary to successfully send things over the web).
To connect our back end to our front end, we needed to insert reference to the task.id into our html string that lives in the "renderTask" function (see interpolation below).
Array & Object Methods
find – returns the first item that matches what you are looking for (kind of like a filter, but just grabs the first one it finds)
findIndex tells us the index of the first item in an array that matches a certain condition *remember count starts at 0]
Object.assign – used to copy the properties from one object onto another
.Splice – used to delete an item from an array, so long as you know what index it lives at. The first argument is the index the item starts at, the second is the # of items you want to delete
.unshift adds an item to the left side of an array
push adds an item to the right side of an array
Connecting front end to the back end The code below sends the information to our server from the website. Note that the "stringify" method turns whatever we are sending through the web into a string (necessary to successfully send things over the web).
const response = await fetch(url) method: "POST" (or other html verb) headers: { 'Content-Type': application/json', 'Accept': application/json' }, body: JSON.stringify({description: form.description.value}) })
To connect our back end to our front end, we needed to insert reference to the task.id into our html string that lives in the "renderTask" function (see interpolation below).
const html = `