Today, I found a challenge that required me to reverse a particular string, so below is the code written in JavaScript to achieve the result.
Method 1:
const str = "JavaScript is awesome"
let reversedString = "";
for(let i = 0; i < str.length; i++){
reversedString = str.charAt(i) + reversedString;
}
reversedString; // Output: "emosewa si tpircSavaJ"
Method 2:
const str = "JavaScript is awesome";
str.split("").reverse().join(""); // Output: "emosewa si tpircSavaJ"
Additional Information:
The string can be tested if it is a palindrome, by comparing the actual string with the reversed string
I hope you found this helpful.