I was doing a simple coderbyte string reverse exercise, but I find I'm having difficulty changing string indexes because having string.charAt()
on the left side of an assignment seems to throw an error. What causes this? What's a better way to access and change characters in a string?
function FirstReverse(str) {
for(var i = 0; i < Math.floor(str.length / 2); i++){
original = str.charAt(i);
str.charAt(i) = str.charAt(str.length - 1 - i);
str.charAt(str.length - 1 - i) = original;
}
return str;
}