how to reverse a string
function reverseString(str) {
return str.split("").reverse().join("");
}
reverseString("hello");
how to reverse a string
function reverseString(str) {
return str.split("").reverse().join("");
}
reverseString("hello");
Reverse string
// Reverse string
function reverseString(str) {
let reverseStr = '';
let i = str.length - 1;
while (i >= 0) {
reverseStr += str[i];
console.log(reverseStr);
i--;
}
return reverseStr;
}
reverseString('hello');
// OR
function reverseString(str) {
for (var reversedStr = '', i = str.length - 1; i >= 0; i--) {
reversedStr += str[i];
}
return reversedStr;
}
// OR
function reverseString(str( {
result = ""
for (i = 0; i < str.length; i++) {
result = str[i] + result
}
return result
}
// OR
function reverseString(str) {
return str.split('').reverse().join('');
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us