diff --git a/challenges/01-front-end-development-certification/advanced-bonfires.json b/challenges/01-front-end-development-certification/advanced-bonfires.json
index e720ebcf90..e14aa63db9 100644
--- a/challenges/01-front-end-development-certification/advanced-bonfires.json
+++ b/challenges/01-front-end-development-certification/advanced-bonfires.json
@@ -89,7 +89,7 @@
"title": "Symmetric Difference",
"description": [
"Create a function that takes two or more arrays and returns an array of the symmetric difference (△
or ⊕
) of the provided arrays.",
- "Given two sets (for example set A = {1, 2, 3}
and set B = {2, 3, 4}
), the mathematical term \"symmetric difference\" of two sets is the set of elements which are in either of the two sets, but not in both (A △ B = C = {1, 4}
). For every additional symmetric difference you take (say on a set D = {2, 3}
), you should get the set with elements which are in either of the two the sets but not both (C △ D = {1, 4} △ {2, 3} = {1, 2, 3, 4}
).",
+ "Given two sets (for example set A = {1, 2, 3}
and set B = {2, 3, 4}
), the mathematical term \"symmetric difference\" of two sets is the set of elements which are in either of the two sets, but not in both (A △ B = C = {1, 4}
). For every additional symmetric difference you take (say on a set D = {2, 3}
), you should get the set with elements which are in either of the two the sets but not both (C △ D = {1, 4} △ {2, 3} = {1, 2, 3, 4}
). The resulting array must contain only unique values (no duplicates).",
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
@@ -100,11 +100,15 @@
"sym([1, 2, 3], [5, 2, 1, 4]);"
],
"solutions": [
- "function sym(args) {\n var index = -1;\n var length = arguments.length;\n var result;\n while (++index < length) {\n var array = arguments[index];\n result = result ? diff(result, array).concat(diff(array, result)) : array;\n }\n return result ? uniq(result) : [];\n}\n\nfunction uniq(arr) {\n var h = Object.create(null);\n var u = [];\n arr.forEach(function(v) {\n if (v in h) return;\n h[v] = true;\n u.push(v);\n });\n return u;\n}\n\nfunction diff(a, b) {\n var h = Object.create(null);\n b.forEach(function(v) {\n h[v] = true; \n });\n return a.filter(function(v) { return !(v in h);});\n}\nsym([1, 2, 3], [5, 2, 1, 4]);\n"
+ "function sym() {\n var arrays = [].slice.call(arguments);\n return arrays.reduce(function (symDiff, arr) {\n return symDiff.concat(arr).filter(function (val, idx, theArr) {\n return theArr.indexOf(val) === idx \n && (symDiff.indexOf(val) === -1 || arr.indexOf(val) === -1);\n });\n });\n}\nsym([1, 2, 3], [5, 2, 1, 4]);\n"
],
"tests": [
"assert.sameMembers(sym([1, 2, 3], [5, 2, 1, 4]), [3, 4, 5], 'message: sym([1, 2, 3], [5, 2, 1, 4])
should return [3, 4, 5]
.');",
"assert.equal(sym([1, 2, 3], [5, 2, 1, 4]).length, 3, 'message: sym([1, 2, 3], [5, 2, 1, 4])
should contain only three elements.');",
+ "assert.sameMembers(sym([1, 2, 3, 3], [5, 2, 1, 4]), [3, 4, 5], 'message: sym([1, 2, 3, 3], [5, 2, 1, 4])
should return [3, 4, 5]
.');",
+ "assert.equal(sym([1, 2, 3, 3], [5, 2, 1, 4]).length, 3, 'message: sym([1, 2, 3, 3], [5, 2, 1, 4])
should contain only three elements.');",
+ "assert.sameMembers(sym([1, 2, 3], [5, 2, 1, 4, 5]), [3, 4, 5], 'message: sym([1, 2, 3], [5, 2, 1, 4, 5])
should return [3, 4, 5]
.');",
+ "assert.equal(sym([1, 2, 3], [5, 2, 1, 4, 5]).length, 3, 'message: sym([1, 2, 3], [5, 2, 1, 4, 5])
should contain only three elements.');",
"assert.sameMembers(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5], 'message: sym([1, 2, 5], [2, 3, 5], [3, 4, 5])
should return [1, 4, 5]
');",
"assert.equal(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]).length, 3, 'message: sym([1, 2, 5], [2, 3, 5], [3, 4, 5])
should contain only three elements.');",
"assert.sameMembers(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]), [1, 4, 5], 'message: sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5])
should return [1, 4, 5]
.');",