Hello,
In this function, I’m comparing 2 strings and returning the characters that aren’t in common. To achieve this, I’m repeating the `for…of
[code]
function returnCharsNotCommon(string1, string2) {
const arr = [];
for (let element of string1) {
!string2.match(element) ? arr.push(element) : “”;
}
for (let element of string2) {
!string1.match(element) ? arr.push(element) : “”;
}
return arr.join(“”);
}
console.log(returnCharsNotCommon(“classics”, “basic”));
Is there a way to make this happen in just 1 statement, but with the parameters alternating automatically?
Thanks for the tip(s)!
Kr,