# reverseCode翻转字符串

function reverseCode(s) {
  const sArr = s.split("");
  let start = 0;
  let end = sArr.length - 1;

  while (start < end) {
    [sArr[start++], sArr[end--]] = [sArr[end], sArr[start]];
  }

  return sArr.join("");
}

console.log(reverseCode("1234"));
1
2
3
4
5
6
7
8
9
10
11
12
13
Last Updated: 6/27/2023, 7:40:45 PM