从第二个JavaScript中删除第一个字符串的所有字符
假设我们有两个字符串,其中包含的字符没有特定的顺序。我们需要编写一个接受这两个字符串并返回第二个字符串的修改版本的函数,其中省略了第一个字符串中存在的所有字符。
以下是我们的字符串-
const first = "hello world"; const second = "hey there";
以下是我们从第二个字符串中删除第一个字符串的所有字符的功能-
const removeAll = (first, second) => {
const newArr = second.split("").filter(el => {
return !first.includes(el);
});
return newArr.join("");
};让我们为该函数编写代码-
示例
const first = "hello world";
const second = "hey there";
const removeAll = (first, second) => {
const newArr = second.split("").filter(el => {
return !first.includes(el);
});
return newArr.join("");
};
console.log(removeAll(first, second));输出结果
控制台中的输出将为-
yt
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短