I've got the following function
expandActions(e) {
const index = this.menuItems[this.element].findIndex((menu) => {
console.log(menu.type === e) // this returns true
menu.type === e
})
console.log(index) // this returns -1
}
this.element = paragraph e = font
Json:
{
"paragraph": [
{
"type": "font",
"icon": "font",
"actions": [
{
"do": "size",
"icon": "text-height"
},
{
"do": "letter-spacing",
"icon": "text-width"
},
]
},
{
"type": "text-align",
"icon": "align-left",
"actions": [
{
"do": "align-right",
"icon": "align-right"
},
{
"do": "align-justify",
"icon": "align-justify"
},
]
}
]
}
Why is FindIndex returning -1 if there is a match with an index? If the function returns true is should return an index right?