Skip to main content
Commonmark migration
Source Link

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


#JavaScript (ES6), 26 bytes

JavaScript (ES6), 26 bytes

Takes input as a string.

s=>s.replace(/./gs,c=>c+c)

Try it online!

Alternate version suggested by @PabloLozano:

s=>s.replace(/./gs,'$&$&')

Try it online!

Doing it the recursive way is also just as long:

f=([c,...s])=>c?c+c+f(s):s

Try it online!

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


#JavaScript (ES6), 26 bytes

Takes input as a string.

s=>s.replace(/./gs,c=>c+c)

Try it online!

Alternate version suggested by @PabloLozano:

s=>s.replace(/./gs,'$&$&')

Try it online!

Doing it the recursive way is also just as long:

f=([c,...s])=>c?c+c+f(s):s

Try it online!

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


JavaScript (ES6), 26 bytes

Takes input as a string.

s=>s.replace(/./gs,c=>c+c)

Try it online!

Alternate version suggested by @PabloLozano:

s=>s.replace(/./gs,'$&$&')

Try it online!

Doing it the recursive way is also just as long:

f=([c,...s])=>c?c+c+f(s):s

Try it online!

added an alternate version
Source Link
Arnauld
  • 197.8k
  • 20
  • 180
  • 650

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


#JavaScript (ES6), 26 bytes

Takes input as a string.

s=>s.replace(/./gs,c=>c+c)

Try it online!


 

Alternate version suggested by @PabloLozano:

s=>s.replace(/./gs,'$&$&')

#JavaScript (ES6), 26 bytesTry it online!

Doing it the recursive way is also just as long.:

Takes input as a string.

f=([c,...s])=>c?c+c+f(s):s

Try it online!

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


#JavaScript (ES6), 26 bytes

Takes input as a string.

s=>s.replace(/./gs,c=>c+c)

Try it online!


 

#JavaScript (ES6), 26 bytes

Doing it the recursive way is just as long.

Takes input as a string.

f=([c,...s])=>c?c+c+f(s):s

Try it online!

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


#JavaScript (ES6), 26 bytes

Takes input as a string.

s=>s.replace(/./gs,c=>c+c)

Try it online!

Alternate version suggested by @PabloLozano:

s=>s.replace(/./gs,'$&$&')

Try it online!

Doing it the recursive way is also just as long:

f=([c,...s])=>c?c+c+f(s):s

Try it online!

fixed the 2nd version
Source Link
Arnauld
  • 197.8k
  • 20
  • 180
  • 650

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


#JavaScript (ES6), 2526 bytes

Takes input as a string.

s=>s.replace(/./ggs,c=>c+c)

Try it online!Try it online!


#JavaScript (ES6), 26 bytes

Doing it the recursive way is just 1 byte longeras long.

Takes input as a string.

f=([c,...s])=>c?c+c+f(s):s

Try it online!

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


#JavaScript (ES6), 25 bytes

Takes input as a string.

s=>s.replace(/./g,c=>c+c)

Try it online!


#JavaScript (ES6), 26 bytes

Doing it the recursive way is just 1 byte longer.

Takes input as a string.

f=([c,...s])=>c?c+c+f(s):s

Try it online!

JavaScript (Node.js), 22 bytes

Takes input as an array of characters.

s=>s.flatMap(c=>[c,c])

Try it online!


#JavaScript (ES6), 26 bytes

Takes input as a string.

s=>s.replace(/./gs,c=>c+c)

Try it online!


#JavaScript (ES6), 26 bytes

Doing it the recursive way is just as long.

Takes input as a string.

f=([c,...s])=>c?c+c+f(s):s

Try it online!

Source Link
Arnauld
  • 197.8k
  • 20
  • 180
  • 650
Loading