Awesome share Matt! (or do you go by Matthew?)
var duplicateNotes = notes.filter((note) => note.title === title)
Your explanation of how it works is correct. Since notes contains a list of javascript object like
{
title: 'Some String'
body: 'whatever'
}
It basically is "filter"-ing out from your array of objects that matches those conditions... in this case "title".
The ((note))
part is arbitrary. You could have put apple
and do the comparison like apple.title === title
.
It is not related to the note
variable you created initially in the addNote function. Hope that helps :)
Thanks, that does help. I appreciate it.
I do go by Matthew.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I am not to up on JavaScript lambda but is this valid, as in no brackets around the param. I know C# only requires the brackets when more than one argument into the lambda.
As you can see, I am a clean code junkie lol The less characters while remaining readable is always better :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit