Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

numbers split

const num = 1234567;
const strNum = String(num);

function getPartialString(str, len) {
  const result = [];
  for (let i = 0; i < strNum.length - (len - 1); ++i) {
    result.push(strNum.slice(i, i + len));
  }
  return result;
}
console.log(getPartialString(strNum, 3));
console.log(getPartialString(strNum, 4));
console.log(getPartialString(strNum, 5));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #numbers #split
ADD COMMENT
Topic
Name
2+8 =