Symmetric Difference

Developer
Size
1,747 Kb
Views
42,504

How do I make an symmetric difference?

What is a symmetric difference? How do you make a symmetric difference? This script and codes were developed by Ben on 08 August 2022, Monday.

Symmetric Difference Previews

Symmetric Difference - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Symmetric Difference</title>
</head>
<body> <script src="js/index.js"></script>
</body>
</html>

Symmetric Difference - Script Codes JS Codes

function unique (value, index, self){ return self.indexOf(value)===index }
function sym(...args) { var arr = args.reduce(function(accum, item){ debugger item=item.filter(unique) var newAccum = accum.filter(element => !item.includes(element)) var newAccum2 = item.filter(element => !accum.includes(element)) newAccum = newAccum.concat(newAccum2) /*newAccum = newAccum.concat(item.filter(element => { debugger; console.log(!accum.includes(element)) return !accum.includes(element) }))*/ /*for (var i=0 ; i<item.length ; i++){ debugger var index = accum.indexOf(item[i]) if (index===-1){ accum.push(item[i]) } else { accum.splice(index,1) } }*/ return newAccum }, []) return arr;
}
console.log(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5])) //should return [1, 4, 5].
console.log(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5])) //should contain only three elements.
console.log(sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3])) //should return [2, 3, 4, 6, 7].
console.log(sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3])) //should contain only five elements.
console.log(sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3], [5, 3, 9, 8], [1])) //should return [1, 2, 4, 5, 6, 7, 8, 9].
sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3], [5, 3, 9, 8], [1]) //should contain only eight elements.
Symmetric Difference - Script Codes
Symmetric Difference - Script Codes
Home Page Home
Developer Ben
Username bencarp
Uploaded August 08, 2022
Rating 3
Size 1,747 Kb
Views 42,504
Do you need developer help for Symmetric Difference?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Ben (bencarp) Script Codes
Name
TESTS
Smallest Common multiple
Promodoro new
SumAllPrimes
MakeAPerson
Weather App
Test
Promodoro
UniteUnique
Twitch Channels
Create amazing art & images with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!