Reverse String DSA Solve In Javascript

In this blog I am going to share a important DSA javascript interview question reverse string in javascript.
Algo Explaination:
We will run the loop till the half of the array. We will have two pointers left and right. left is the 0th index and right is the length -1 index. Next in every iteration we will replace the left element with right and right element with left.
var reverseString = function(s) {
let left = 0;
let right = s.length-1;
while(left<=right){
let temp = s[left];
s[left] = s[right];
s[right] = temp;
left++;
right--;
}
};



