1the_world_is_flat=true
2# ...do something interesting...
3if [ "$the_world_is_flat" = true ] ; then
4 echo 'Be careful not to fall off!'
5fi
1function diffArray(arr1, arr2) {
2 return arr1
3 .concat(arr2)
4 .filter(item => !arr1.includes(item) || !arr2.includes(item));
5}
1const diffArray = (arr1, arr2) => {
2 // Store the different elements
3 const diffArray = []
4 // Concat both arrays
5 const uniqueArr = [...new Set([...arr1, ...arr2])];
6 // OR const uniqueArr = [...new Set(arr1.concat(...arr2))]
7
8 // Loop through the unique array and confirm that each element in it
9 // is in both arrays(arr1,arr2), else push element not found in both
10 // arrays to the diffArray and return it
11 uniqueArr.forEach(elem => {
12 if(!arr1.includes(elem) || !arr2.includes(elem))
13 diffArray.push(elem)
14 })
15 return diffArray
16}
17
18diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
19// With love @kouqhar