How do you reverse a string in place (or in-place) in JavaScript when it is passed to a function with a return statement, without using built-in functions (.reverse()<
.reverse()<
Strings themselves are immutable, but you can easily create a reversed copy with the following code:
function reverseString(str) { var strArray = str.split(""); strArray.reverse(); var strReverse = strArray.join(""); return strReverse; } reverseString("hello");