Created
March 5, 2022 21:06
-
-
Save natafaye/78215da66e66d0434bc2b465d1d77817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.codewars.com/kata/56b1f01c247c01db92000076/train/javascript | |
function doubleChar(str) { | |
let result = ""; | |
// loop over the string | |
for(let i = 0; i < str.length; i++) { | |
// get the character that we're at for this looping | |
const character = str[i]; | |
// add the doubled character to the result | |
result += character + character; | |
} | |
return result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The fancy map way :) | |
function doubleChar(str) { | |
return str.split('').map(character => character + character).join('') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment