JSFiddle - React, Tailwind, and code Playground

by Dave Mednick

JavaScript

var myArray = [
    [364, 124],
    [192, 272],
    [209, 217],
    [332, 227],
    [241, 273],
    [356, 387],
    [104, 185],
    [361, 380],
    [297, 390],
    [371, 311],
    [191, 293]
];

function distTen(element, index, array) {
    for (x = 0; x < 10; x++) {
        if (Math.abs(element[0] - array[x][0]) < 10) array[x][0] += 10;
        if (Math.abs(element[1] - array[x][1]) < 10) array[x][1] += 10;
    }
}

function logIt(element, index, array) {
    console.log("a[" + index + "] = " + element);
}
myArray.forEach(distTen);
myArray.forEach(logIt);