Open this example in the interactive library
Source code
const grid = 8;
console.log([19, 26].map((v) => Math.round(v / grid) * grid));
Sample output
[ 16, 24 ]

Open this example in the interactive library
const grid = 8;
console.log([19, 26].map((v) => Math.round(v / grid) * grid));
[ 16, 24 ]