You are viewing a single comment's thread from:

RE: Saving Notes to a JSON file: Day Six of "The Complete Node.js Developer Course"

in #javascript7 years ago

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 :)

Sort:  

Thanks, that does help. I appreciate it.

I do go by Matthew.

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.

var duplicateNotes = notes.filter(note => note.title === title)

As you can see, I am a clean code junkie lol The less characters while remaining readable is always better :)

Coin Marketplace

STEEM 0.20
TRX 0.12
JST 0.028
BTC 64400.67
ETH 3506.16
USDT 1.00
SBD 2.53