#7DaysJS: Reverse a String
Lautaro Lobo

Lautaro Lobo @lautarolobo

About: While you read this I'm learning something new.

Location:
Córdoba, Argentina
Joined:
May 6, 2019

#7DaysJS: Reverse a String

Publish Date: Dec 3 '19
5 2

Welcome to day 4 of 7 Days of JavaScript!

Today we will see how to reverse a string. It’s probably the most asked question ever on technical interviews.

So the statement is quite simple, although the problem has an unexpected complexity when you face it for the first time: write a function that takes a string and returns the string reversed.

Here’s an example:

reverseString('Japan')
...
'napaJ'

Enter fullscreen mode Exit fullscreen mode

Give it a try.

You can see the solutions I made here.

Comments 2 total

  • Bharath_Bheemireddy
    Bharath_BheemireddyDec 3, 2019
    
    const reverseString = str => str.split('').reverse().join('');
    
    • Lautaro Lobo
      Lautaro LoboDec 3, 2019

      That's I think the best way to do it!

Add comment