/** * 反转字符串 */ const reverseString = (str = 'hello world') => { const arr = str.split('') let startIndex = 0, endIndex = arr.length while(startIndex < endIndex) { let s = arr[startIndex] arr[startIndex] = arr[endIndex] arr[endIndex] = s startIndex++ endIndex-- } return arr.join('') }
标签:endIndex,arr,const,反转,startIndex,字符串 From: https://www.cnblogs.com/zhenjianyu/p/17077308.html