I'm having a hard time understanding why this is returning "5Style is not a function"
NationalLevelCategoriesChosenList = [
["5Style", "5MelodyHarmony", "5RhythmTempo", "5TextureStructureForm", "5Timbre"]
], [
[]
];
if (NationalLevelCategoriesChosenList[0].some("5Style")) {
console.log("working")
}
The some() function allows you to test a value with a provided function. I think you want to use includes() instead ? Please see snippet below.
NationalLevelCategoriesChosenList = [
["5Style", "5MelodyHarmony", "5RhythmTempo", "5TextureStructureForm", "5Timbre"]
], [
[]
];
if (NationalLevelCategoriesChosenList[0].includes('5Style')){
console.log("working")
}
See the documentation for some:
The some() method tests whether at least one element in the array passes the test implemented by the provided function.
The argument you are passing "5Style" is a string, not a function.
You are probably looking for the includes method:
NationalLevelCategoriesChosenList[0].includes("5Style")
But if you wanted to use some then you need to write a function:
NationalLevelCategoriesChosenList[0].some((current_value) => curent_value === "5Style")