0

What does the ~ symbol do in the ~j and ~rdo?

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

Alexey Tseitlin
  • 1,031
  • 4
  • 14
  • 33

0 Answers0