Tech_Dev
this page is going to be about web technologies where people can share technology and also learn web technologies.
Symmetry difference Algorithm
function sym() {
const args = [];
for (let i=0; i< arguments.length; i+=1) {
args.push(arguments[i]);
}
return args.reduce((acc, curArr) => {
let ac = [...acc];
const result = [];
for (let i=0; i< ac.length; i+=1) {
if(curArr.indexOf(ac[i])== -1 && result.indexOf(ac[i]) == -1){
result.push(ac[i]);
}
}
for (let i=0; i< curArr.length; i+=1) {
if(ac.indexOf(curArr[i]) == -1 && result.indexOf(curArr[i])==-1) {
result.push(curArr[i]);
}
}
return [...result];
});
}
console.log(sym([1, 2, 3], [5, 2, 1, 4]));
Output: [ 3, 5, 4 ];
Click here to claim your Sponsored Listing.
Category
Contact the business
Telephone
Address
Gurugram
Gurugram
122505