此函数在没有 .toUpperCase 方法的情况下工作。但我想让它与 toUpperCase 一起工作。我该怎么办?我目前正在从 udemy 课程学习 Javascript:
const notes = [
{},{
title: 'My next trip',
body: 'I would like to go to Spain'
}, {
title: 'Habbits to work on',
body: 'Excercise, Eat a bit better'
}, {
title: 'Office modification',
body: 'Get a new seat'
}]
function findNote(notes, noteTitle){
const index = notes.findIndex(function(item, index){
return item.title.toUpperCase() === noteTitle.toUpperCase()
})
return notes[index]
}
const note = findNote(notes, 'Office modification')
console.log(note)
冉冉说
精慕HU
相关分类