Wherefore art thou WHY OH WHY

But why does this log false?

Your code so far


function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  
var muppa = { last: "Capulet" };
var ios = { last: "Capulet" };

if (muppa === ios) {
  console.log (true)
} else {
  console.log(false)
};

  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15.

This is because muppa and ios are 2 separate objects. Comparing objects isn’t the same as comparing values, sadly!

Just a tip, by the way, you can write that last bit in one line of code by writing:

“console.log(muppa === ios);”

And it will return true or false by itself

1 Like