2016-05-21 41 views

回答

0

你可以得到每你的數字和循環中的字符爲文本增加空間。

var text = "1010101010101010"; 
 
var charac = text.split(""); 
 

 
var newText = ""; 
 
charac.forEach(function(value, index){ 
 
    if (index % 4 == 0) 
 
     newText += " "; 
 
     
 
    newText += value; 
 
}); 
 

 
document.write(newText);

相關問題