Using flat() and includes() Simple reference provided for you
function weatherCodes(){
let codes = [{sunny:[1001]},{cloudy:[1002,1003]}]
let theCode = 1003
return codes.some(c => Object.values(c).flat().includes(theCode));
};
console.log(weatherCodes());
Another option
function weatherCodes(){
let codes = [{sunny:[1001]},{cloudy:[1002,1003]}]
let theCode = 1003
let values = codes.flatMap(c => Object.values(c)).flat()
return values.includes(theCode)
};
console.log(weatherCodes());
Using
flat()
andincludes()
Simple reference provided for youAnother option