我需要的是删除原始字符及其重复项,不论其是小写还是大写。同时保留它是大写还是小写。
以下是我的当前代码,但它无法过滤大小写的字符串。
以下是我的当前代码,但它无法过滤大小写的字符串。
const removeDuplicateChar = s => s
.split('')
.filter( ( cur, index, self ) => self.lastIndexOf( cur ) === self.indexOf( cur ) )
.join('')
实际输出
'services' becomes 'rvic'
'stress' becomes 'tre'
'ServicEs' becomes 'ServicEs'
'streSs' becomes 'treS'
'DeadSea' becomes 'DdS'
预期输出
'services' should be 'rvic'
'stress' should be 'tre'
'ServicEs' should also be 'rvic'
'streSs' should also be 'tre'
'DeadSea' becomes 'S'