index.tsx122 chars6 lines
The reverseString
function takes a string as an argument (str
). It then uses the split("")
method to split the string into an array of characters. The reverse()
method is called on the array to reverse the order of the characters. Finally, the join("")
method is used to join the characters back together into a string. The reversed string is returned as the output of the function.
In this case, when we call reverseString("malena")
it will output "anelam", which is the string "malena" backwards.
gistlibby LogSnag