let name = "anurag";
console.log(name.split("").reverse().join(""));
let name = "anurag";
console.log([...name].reverse().join(""));
let name = "anurag";
for (let i = name.length - 1; i >= 0; i--) {
finalname += name[i];
}
console.log(finalname);
let name = "anurag";
let length = name.length - 1;
let finalname = "";
while (length >= 0) {
finalname += name.charAt(length);
length--;
}
console.log(finalname);
let name = "anurag";
let length = name.length - 1;
let finalname = "";
while (length >= 0) {
finalname += name.substr(length);
name = name.slice(0, -1);
length--;
}
console.log(finalname);
const reverseString = (str) => {
return str === "" ? "" : reverseString(str.substr(1)) + str.charAt(0);
};
let x = reverseString("anurag");
console.log(x);