Reverse a String Incomplete * Should i no this by now.?

Reverse a String Incomplete * Should i no this by now.?
0

#1

So i have reached the section Basic Algorithm Scripting and my first question is on Reverse a String.
Now is it wrong that i have got to this point and DONT quite understand how it's done? or in your opinion is it ok to read or watch a video on how it's done .just wondering if maybe i am not taking it all in.


#2

prob the cleanest version i found on this .
return str.split("").reverse().join("");


#3

It’s ok to approach this however you like :slight_smile:

My method for solving problems with the algorithms is to think about what I have as a piece of data, in this case a string, and then looking up what methods I can use on that data type.

So in your example split() is an interesting one because it gives you a new data type (an array).

So then you can look up the methods on that, like reverse() and join().

Do be discouraged if you need to look things up though. The algorithm challenges are designed to stretch your problem solving reasoning and introduce you to new methods. Look up code if you need to, but always find out what it means and why it works :slight_smile:

Happy coding!