I need to detect if the values of an array are present in an object as a key
I tried this way
var color = {
1: "Red",
2: "Blue",
3: "Yellow",
4: "Violet",
5: "Green",
7: "Orange"
};
var myColor = [3, 1];
for(const [key, value] of Object.entries(color)){
var bgIco = (myColor.includes(key)) ? '[' + key + ']' + value + ' - Yes' : '[' + key + ']' + value + ' - No';
console.log(bgIco);
}
But it always comes back no
If in the includes function I manually put a number in the object instead of the key variable then it works, what am I doing wrong?