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'))