how to chunks an array into equal code example
Example 1: array chunk javascript
//#Source https://bit.ly/2neWfJ2
const chunk = (arr, size) =>
Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>
arr.slice(i * size, i * size + size)
);
console.log(chunk([1, 2, 3, 4, 5], 2));
Example 2: array chunk javascript
const tips_vectorDistance = (x, y) =>
Math.sqrt(x.reduce((acc, val, i) => acc + Math.pow(val - y[i], 2), 0));
console.log(tips_vectorDistance([15, 0, 5], [30, 0, 20]));