在js中将字符串中的每个字母加倍

Art*_*thi 1 javascript

我需要字符串中每个字母的字符串Double

abc - > aabbcc

我试试这个

var s = "abc";
for(var i = 0; i < s.length  ; i++){
   console.log(s+s);
}
Run Code Online (Sandbox Code Playgroud)

O/P

>     abcabc    
>     abcabc  
>     abcabc
Run Code Online (Sandbox Code Playgroud)

但是我需要

为aabbcc

帮我

Pra*_*lan 6

使用String#split,Array#mapArray#join方法.

var s = "abc";

console.log(
  // split the string into individual char array
  s.split('').map(function(v) {
    // iterate and update
    return v + v;
    // join the updated array
  }).join('')
)
Run Code Online (Sandbox Code Playgroud)