var str = "春节快要放假了,好开心呀!"var strArr = [];var n = 3;for (var i = 0, l = str.length; i < l/n; i++) {var a = str.slice(n*i, n*(i+1));strArr.push(a);}console.log(strArr);结果:["春节快", "要放假", "了,好", "开心呀", "!"]
1200字范文,内容丰富有趣,写作的好帮手!
时间:2019-02-10 03:01:01
var str = "春节快要放假了,好开心呀!"var strArr = [];var n = 3;for (var i = 0, l = str.length; i < l/n; i++) {var a = str.slice(n*i, n*(i+1));strArr.push(a);}console.log(strArr);结果:["春节快", "要放假", "了,好", "开心呀", "!"]