js去掉字符串中最后一个指定的字符
let str = " zifu chuan "
function func(str, target)
{
let arr = str.split('')
arr.map(function(item, index){
if(item === target){
arr.splice(index, 1)
}
})
return arr.join('')
}
console.log(func(str, 'n'))
这是我的签名
浙公网安备 33010602011771号