mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
16 lines
332 B
JavaScript
16 lines
332 B
JavaScript
function comp(array1, array2){
|
|
let squares = [];
|
|
for (let num of array1) {
|
|
squares.push(num * num);
|
|
}
|
|
|
|
if (!array2)
|
|
return false;
|
|
|
|
for (let square of array2) {
|
|
let index = squares.indexOf(square);
|
|
if (index != -1) squares.splice(index, 1);
|
|
}
|
|
if (squares.length > 0) return false;
|
|
else return true;
|
|
}
|