Created
October 14, 2019 02:39
-
-
Save xx19941215/078a45facdc1689e998d8e0dcd5c1481 to your computer and use it in GitHub Desktop.
按照指定长度间隔分割字符串.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = (source, count) => { | |
let arr = []; | |
for (let i = 0, len = source.length / count; i < len; i++) { | |
let subStr = source.substr(0, count); | |
arr.push(subStr); | |
source = source.replace(subStr, ""); | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment