michaelp0730
8/9/2018 - 4:49 AM

Chunk String

chunkString('1234', 2) returns [12, 34] chunkString('123456789', 3) returns [123, 456, 789]

function ChunkString(str, length) {
    return str.match(new RegExp('.{1,' + length + '}', 'g'));
}