What does the ~
symbol do in the ~j
and ~r
do?
sc=a=>[a.findIndex(r=>j=~r.indexOf('B')),~j];
It would be executed like this sc(array)
where a
is an array:
let a = [
["B", "A", "A", "A", "A"],
["A", "A", "A", "A", "A"],
["A", "A", "A", "A", "A"],
["A", "A", "A", "A", "A"],
["A", "A", "A", "A", "A"]
];
console.log( sc(array) );
This is a solution to http://www.codewars.com/kata/shortest-code-bug-in-apple/javascript