Take string and make a 2d array of it but starting from the right, needs array element size.

PHOTO EMBED

Wed May 18 2022 00:49:11 GMT+0000 (Coordinated Universal Time)

Saved by @owent #javascript

let number = "10145";


//put number into array of arrays like 10145 becomes [ [ '1', '0' ], [ '1', '4', '5' ] ]
let numArray = number.split("");
const chunkRight = (arr, size) => {
    const rm = arr.length % size;
    
    return rm ?
      [arr.slice(0, rm), ..._.chunk(arr.slice(rm), size)]
      :
      _.chunk(arr, size);
};
const result = chunkRight(numArray, 3);
content_copyCOPY