Our coding challenge today is called "reverse a string". We are going to create a function that will accept one argument, which will be a string, within our function we will write code that will reverse the string that we will decide to pass in as an argument.

Please try to complete the challenge yourself first before checking out my solution.

const reverseAString = (str)=>{
    const s = str.split("").reverse().join("")
    return s
}

console.log(reverseAString("keep coding"));

// output = gnidoc peek

What we should take away from this challenge is that there is no built in method for reversing a string (well, at least when I was writing this), so in order for us to be able to reverse a string we should first turn it into an array. To turn a string into an array we have to use the built in string split method. Then from there that is when we can use the built in array reverse method to reverse what was initially a string. But still our job is not yet done because we still have a reversed array instead of a string, so now our only job is to use the built in array join method, which will convert our array into a string. Now we will return a reversed string from every parameter we pass in.