Last active
January 6, 2024 14:43
-
-
Save MarwanShehata/b61487a9133f2cebbc9c06de323a9e72 to your computer and use it in GitHub Desktop.
This file contains 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
function joinElements(arr, joinString) { | |
function recurse(i, resultSoFar) { | |
resultSoFar += arr[i]; | |
console.log(resultSoFar); | |
if (i === arr.length - 1) { | |
return resultSoFar; | |
} else { | |
return recurse(i + 1, resultSoFar + joinString); | |
} | |
} | |
return recurse(0, ""); | |
} | |
joinElements(["s", "cr", "et cod", " :) :)"], "e"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment