Somebody please explain me this code in detail
function reverse(s){
return s.split("").reverse().join("");
}
The function takes a string, it splits it in its constituent characters to obtain an array using the split function, it reverses this array using the reverse method and joins the elements with an empty string.
Basically it reverses a string which given the name of the function I guess doesn't come as a surprise to anyone.
So:
reverse('abc')
will return:
cba
reversemethod of Array is used to reverse the order of the array's elements. Then, the string is concatenated again, using an empty string.