題目
難度:easy
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
第一次解法
/**
* @param {string} s
* @return {string}
*/
var reverseString = function(s) {
let l = s.length
let res = ''
while(l>0){
res += s.charAt(l-1)
l--
}
return res
};# runtime : 80ms