First we'll create a function called revereString
function reverseString(str){
return reversedString;
}
Inside the reverseString we will create a variable called reversedString and return it.
function reverseString(str){
var reversedString;
return reversedString;
}
Now let's set the reversedString variable to this:
function reverseString(str){
var reversedString = str.split("").reverse().join("");
return reversedString;
}
To test the program run this
var string = "Hello";
var output = reverseString(string);
console.log(output);
// Expected output "olleH"