mercredi 22 août 2018

JavaScript: TypeError cant read property 'toLowerCase' of undefined?

I am getting error while running this code , it's saying typeerror cant read property to 'lowercase' of undefined. Code:-

const notes = [{},{
    title: "My next Trip",
    body: "I would like to go to USA"
},{
    title: "Habbits to work on",
    body: "Exercise"
} ,{
    title: "Office Modification",
    body: "Get a new seat"
} ]

 const findNote = function(notes, noteTitle) {
     const index = notes.findIndex(function (note , index) {
         return note.title.toLowercase() ===  noteTitle.toLowerCase()
     })
     return notes[index]
 }
const note = findNote(notes, "Office Modification")
console.log(note);




Aucun commentaire:

Enregistrer un commentaire