String reversals are one of the most common questions on tech interviews. There are many different ways to do this and one way I’d like to do this is by using the built in JavaScript methods.
function reverse(string) {return str.split('').reverse().join('')}reverse('hello there')
Breaking down each method:
We call .split('') on the the string which separates each character into its own element. It returns ["h", "e", "l", "l", "o", " ", "t", "h", "e"…