function reverse(str){
var i = 0;
for(var j = str.length - 1; j > 0; j--){
for (i = 0; i < j; i++) {
temp = str[i];
str[i] = str[j];
str[j] = temp;
}
}
return str
}
const str = 'abcde'
function reverseString(str) {
let tempString = ''
for(let j = str.length - 1; j >= 0; j--){
tempString += str[j]
}
return tempString
}
console.log('str:', str)
console.log('reverse:', reverseString(str))
const str = 'abcde'
function reverseString(str) {
return str.split('').reverse().join('')
}
console.log('str:', str)
console.log('reverse:', reverseString(str))
str[i] = "x"
Так можно только читать.function reverse(str) {
var i, len = str.length, result = "";
for (i = len - 1; i >= 0; i--) result += str[i];
return result;
}