从第二个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 身体康复的祝福语简短
18 幼师春节祝福语简短创意