Answers for "how to split verybig string javascript"

2

javascript string into substrings of length

function chunkSubstr(str, size) {
  const numChunks = Math.ceil(str.length / size)
  const chunks = new Array(numChunks)

  for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
    chunks[i] = str.substr(o, size)
  }

  return chunks
}
Posted by: Guest on March-05-2020

Code answers related to "how to split verybig string javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language