Here is a part of my object
const category = {
fr: {
list: [
{id: 1, label: 'coucou'},
{id: 2, label: 'moi'},
{id: 3, label: 'ici'},
{id: 4, label: 'maintenant'},
{id: 5, label: 'demain'},
]}}
const lang = fr;
const anyId = 3;
I don't know why when doing the following:
const result = category[lang].list.find(item => item.id === anyId) console.log(result)
Throws the following:
// undefined category[lang].list.find(item => item.id === anyId) is not a function, or just undefined
same result for .map or .filter
console.log(category)
returns no errorconsole.log(category[lang])
returns no errorconsole.log(category[lang].list)
returns no error
but anything else will return an error. It drives me crazy, any help will be highly appreciated.