一个简单的问题。我正在学习Javascript,但是我不明白为什么 slice() 对我的响应 let 没有任何影响。
accum() 是一个接受字符串的函数。
function accum(s) {
let response = '';
for (i=0; i < s.length; i++) {
response += (s.charAt(i).toUpperCase()) + (s.charAt(i).toLowerCase()).repeat(i) + '-'
}
return response.slice(0, response.length-1)
}
console.log(accum("abCdEf"))
response
,就好像我没有对其进行切片一样。