String Reversal in #javascript
▻https://hackernoon.com/string-reversal-in-javascript-22651e20578d?source=rss----3a8144eabfe3---
Photo by Fancycrave on UnsplashString reversal is a very common interview question, and luckily it’s quite simple. There are many different ways to do this, but here are four methods, starting from the simplest and going to the most complex.Use arraysThis is a very straightforward method that leverages existing language features in order to accomplish a task. Most interviewers would ask you to perform the same task in a more ‘manual’ way if you tried this, but it demonstrates an awareness of Javascript, and is what I’d use in real life to accomplish this.Javascript allows you to call the reverse method on arrays. You can see some examples in the documentation here.So we would create a function that does the following:Converts the string to an arrayReverses the arrayTransforms the array back (...)