hello_hello

spliter

Apr 29th, 2020
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function spliter(n) {
  2.   const arr = []
  3.  
  4.   return function(str) {
  5.    const x = (str.length / n).toFixed()
  6.    let m = n
  7.  
  8.    for (let i = 0; i < str.length; i = i + n ) {
  9.      let y = str.slice(i, m)
  10.      arr.push(y)
  11.      console.log(i, m)
  12.      m+=n
  13.    }
  14.    
  15.    return arr
  16.   }
  17. }
  18.  
  19. let x = '123456789'
  20.  
  21. console.log(spliter(3)('12345678910123'))
Advertisement
Add Comment
Please, Sign In to add comment