Write a function that reverses a string. The input string is given as an array of characters char[].
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
You may assume all the characters consist of printable ascii characters.
// reverse를 사용하지 않는 방법
var reverseString = function(s) {
let left = 0;
let right = s.length-1;
while(left < right) {
let tmp = s[left];
s[left] = s[right];
s[right] = tmp;
left++;
right--;
}
return s;
};
// reverse를 활용한 방법
var reverseString = function(s) {
return s.reverse();
};