删除一个字符串中前面出现过的字符,只保留首次出现的字符, 例如
"hello it is a test and you can do it will"。
输出结果为:"helo itsandyucw"
function removeDuplicate(s) { let result = ""; for (let i = 0; i < s.length; i++) { if (s.indexOf(s[i]) == i) { result = result + s[i]; } } return result; } console.log(removeDuplicate("hello it is a test and you can do it will"))