Search
 
SCRIPT & CODE EXAMPLE
 

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));
Comment

PREVIOUS NEXT
Code Example
Javascript :: sessionstorage in js 
Javascript :: value js 
Javascript :: react navigation header title 
Javascript :: 10 to the power of negative n 
Javascript :: react native panresponder on click 
Javascript :: react native basic template 
Javascript :: js code for webpage download progress bar 
Javascript :: json api demo 
Javascript :: discord js channel send 
Javascript :: factory function vs constructor javascript 
Javascript :: how to remove an object from javascript array 
Javascript :: remove last character from string javascript 
Javascript :: read and save excel with react 
Javascript :: cypress run all files in folder 
Javascript :: node.js global variables 
Javascript :: buffer concat nodejs 
Javascript :: fetch composition API in Vue3 
Javascript :: check property exists 
Javascript :: update data in sequelize 
Javascript :: find vs filter 
Javascript :: what is process.env.NODE_ENV 
Javascript :: scrollintoview 
Javascript :: array unshift 
Javascript :: file upload with progress bar 
Javascript :: how to change port in next js 
Javascript :: Create array literal 
Javascript :: Javascript first example 
Javascript :: try catch throwing error in javascript 
Javascript :: javascript comment 
Javascript :: check items in array javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =