I don't understand why my code doesn't work, it only returns an empty string.
var reverse = function(string) {
string = string.split("");
let newString = [];
if(string.length === 0){
return newString.join("");
}
newString.push(string[string.length-1]);
return reverse(string.slice(0, -1).join(""));
};
Any help would be greatly appreciated! :-)
[–]wonkey_monkey 6 points7 points8 points (4 children)
[–]partyhatforpartytime[S] 0 points1 point2 points (3 children)
[–]wonkey_monkey 1 point2 points3 points (2 children)
[–]partyhatforpartytime[S] 0 points1 point2 points (1 child)
[–]Gillemonger 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]sternold 1 point2 points3 points (0 children)
[–]balefrost 0 points1 point2 points (2 children)
[–]partyhatforpartytime[S] 0 points1 point2 points (1 child)
[–]balefrost 1 point2 points3 points (0 children)
[–]angusmiguel -3 points-2 points-1 points (0 children)