xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

js & get recursive ids

js & get recursive ids

len = 0; bug


for(let i = 0; i < 3; i++) {
    console.log(`i =`, i);
	let y = ids.slice(3*i, 3*i + 3);
	console.log(`y =`, y, typeof(y));
    if(i < len - 1) {
	   x += (y + `,`);
       console.log(`x1 =`, x);
	} else {
	   x += `${y}`;
       console.log(`x2 =`, x);
	}
    console.log(`x3 =`, x);
};

OK


const ids = `101103105`;

let len = ids.length / 3;

let x = ``;

for(let i = 0; i < len; i++) {
    console.log(`i =`, i);
	let y = ids.slice(0, 3*i + 3);
        // let y = ids.slice(3*i, 3*i + 3);
	console.log(`y =`, y);
    if(i < len - 1) {
	   x += `${y},`;
	} else {
	   x += `${y}`;
	}
    console.log(`x =`, x);
};

shit api

posted @ 2019-01-17 20:05  xgqfrms  阅读(126)  评论(0编辑  收藏  举报