how to reverse a string in javascript without using reverse method