Question:
Write a function to reverse a string
Approach:
- Create an empty list
- Loop the list in reverse
- Append the result to empty array.
Code Syntax:
string.charAt[i]
string[i]
Other thoughts
- Maybe inplace replacement using left and right pointer could be useful
- one liner possible
Stupid Mistakes
-
1st attempt
- instead of returning result string, was happy with console logging from the loop
- Had to google how to append elements to a string in JS
- struggled with reverse iterating loop