Help me to understand this code?

Tell us what’s happening:
I want to know that
(Array: missingWordArr ) when i pass the (str =“abcdefghijklmnopqrstuvwxyz”)
why( console.log(missingWordArr === )) this one give me false value ?
when i console.log(missingWordArr) it gives me array.
Your code so far


function fearNotLetter(str) {
 let alphabet ="abcdefghijklmnopqrstuvwxyz";
 let firstIndex = alphabet.indexOf(str[0]);
 let lastIndex = alphabet.indexOf(str[str.length-1]);
 let newStr = alphabet.slice(firstIndex,lastIndex+1);
let missingWordArr = newStr.split("").filter((el) => 
  !str.split("").includes(el)
  )  

console.log(newStr, missingWordArr);
console.log(missingWordArr === []);
console.log(missingWordArr === [] ? undefined:missingWordArr.join(""));

}

fearNotLetter("abce");
fearNotLetter("abcdefghijklmnopqrstuvwxyz");
fearNotLetter("stvwx");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36.

Challenge: Missing letters

Link to the challenge:

When you compare two arrays with a === you will always get false. Arrays are objects and objects are compared by reference (the location in memory) to see if they are the same object, not whether they are objects that contain the same values.

2 Likes