let str = 'I Love You';
function r(n) {
let newStr = n.split('').reverse().join('');
console.log(newStr);
}
r(str)
方法2:遍历str,charAt() 是提取字符串的一个字符
let str = 'I Love You';
let newStr = '';
function r(n){
for(let i =0;i<n.length;i++){
let s = n.charAt(str.length-i-1);
console.log(s);
newStr+=s;
}
console.log(newStr);
}
r(str)