function reverseString(string) {
//convert the string to an array
let array = string.split("");
//Use the reverse method
array.reverse()
//Convert it back to a string and return
return array.join("")
}
const reverseString = (string) => string.split("").reverse().join('');
function reverse(str) {
let reverseString = "";
for (let character of str) {
reverseString = character + reverseString;
}
return reverseString
}
function reverseString(string) {
//convert the string to an array
const array = string.split('');
//use the reduce method to convert the array to a reversed string
const reversedString = array.reduce((reversed, character) => {
return character + reversed
}, '')
return reversedString
}
const reverseString = (string) => {
return string.split('').reduce((reversed, character) => character + reversed, '')
}
const reverseString = (string) => string.split('').reduce((rev, char) => char + rev, '')