DEV Community

ZeeshanAli-0704
ZeeshanAli-0704

Posted on

Reverse String - without reverse function

var reverseString = function(arr) {
  if (arr.length === 1) {
    return arr;
  }
  const temp = arr.shift();
  reverseString(arr);
  arr.push(temp);
  return arr;
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)