Hello C_Slater, thanks for reaching out
We’re using map to cycle through the array and replace the contents of the array with either the coordinates (B1, C2, etc) or false (for anything that doesn’t pass the conditional statement “h===g” ie. is the content “^” or “~”, etc.)
After that map cycles through we’re left with an array resembling [false,false,false,“C4”, false, false,“C7”, false false]
Filter is then going through and checking whether z is true, if so, keep it, if false, remove it.
This results in an array that contains only [“C4”, “C7”]
Map replaces contents in the array but doesn’t remove contents.
We could use filter instead of map, but the we’d be left with ["~","~"] instead of [“C4”, “C7”] and lose the index data to know which position they were in (f & i)
Does that help clarify?
In short .filter(z=>z) is cycling through and removing everything in the array that is false.