-2

We need to be able to test if two cells are the same. Complete the function named same that accepts two cells and returns a Boolean indicating if the two cells are the same.

function same([x, y],[j, k]) {
a = same.this [x,y],[j,k];
a.forEach(function(sem){
console.log(sem());
})
 } 

Error Message: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

Knowexx Ke
  • 51
  • 3
  • 13
  • is this helpful for you https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript/16430730 ? – nima Oct 02 '21 at 09:22
  • Does this answer your question? [How to check if two arrays are equal with JavaScript?](https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript) – nima Oct 02 '21 at 09:22
  • 1
    `x === j && y === k`?! "I have no idea where to start" is usually a very bad indicator for the course - either it didn't provide the means needed, or didn't reprimand you properly for not paying attention at all. – ASDFGerte Oct 02 '21 at 09:27

1 Answers1

0

You can try this, you can change the 3 equal signs (===) to 2(==). In case of comparing string and integer values like 2 and "2".

function same([x, y],[j, k]) {
  if(x===j && y===k){
    console.log(true);
  }
  else{
    console.log(false);
  }
}
same(["a","b"],["c","b"])
same(["a","b"],["a","b"])

nodabasi
  • 58
  • 6