const v = new Array(8);
for(let i = 0; i < v.length; i++) {
v[i] = [
Math.pow(-1, i),
Math.pow(-1, Math.floor(i/2)),
Math.pow(-1, Math.floor(i/4))
];
}
Here is a piece of code I wrote that generates the coordinates for the 8 vertices of a (±1, ±1,±1) cube.
Can you tell how it works?