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))
CodePudding user response:
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"])