Ad

Write a function to rotate a two-dimensional array 90 degrees clockwise, and name it rotateArray. The array is always a perfect rectangle.

const rotateArray = m => m[0].map((_,i)=>m.map(r=>r[i]).reverse());
// todo: make it work for empty arrays

Come up with a creative way to replicate the functionality of Math.sign() (extra credits for not using the Math module at all).

The function should be named numberSign, and it should return +1 for positive numbers, -1 for negative, and 0 for 0.

const numberSign = x => x/Math.abs(x) || 0;