Implemented "reverse" JS function