从第二个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 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短