This might be a stupid question but I need to ask!

So, my code below returned false but it didn’t complete the task. I don’t think I can use two dot notation methods in a single line. Am I right? Also, why did my code work but not complete the task? Here’s a link to the task: isTheDinnerVegan()

const isTheDinnerVegan = arr => {
  if(arr.every.source === 'plant') {
    return true;
  }
  return false;
}
const dinner = [{name: 'hamburger', source: 'meat'}, {name: 'cheese', source: 'dairy'}, {name: 'ketchup', source:'plant'}, {name: 'bun', source: 'plant'}, {name: 'dessert twinkies', source:'unknown'}];

console.log(isTheDinnerVegan(dinner))
// Should print false

Hi there.

I presume you’re referring to this line?

  if(arr.every.source === 'plant') {

If so, yes - I think you’re correct.

Array.prototype.every() is a method of the Array object, which you are attempting to access as though it were a property of the object.

You need to call it as arr.every() and provide an appropriate callback function to verify whether every item in the dinner is indeed vegan. :slight_smile:

Hope that helps.

2 Likes