I have a function that loops through an object that currently returns 5 values. The last value it returns will always be undefined.
I would like to execute some code only if all 4 value.valueId === 2
This is what I have right now
Object.values(answers['3']).forEach(value => {
console.log('checkboxValues', value.valueId)
if (value.valueId === 2) {
console.log('I AM 2')
} else {
console.log('I AM SOMETHING ELSE')
}
})
How do I check if all value.valueId === 2 ?
answers[3]? - don't seeanswersarray defined anywhere.answersis an object, the function is executing code on the 3rd nested object that is inside ofanswers