← Back to challenges

Three Arrays!

JavaScriptHardarraysinterviewmathnumbers

Instructions

Given three arrays of integers: arr1, arr2, arr3, return the sum of integers which are common in all three arrays.

Examples

sumCommon([1, 2, 3], [5, 3, 2], [7, 3, 2]) ➞ 5
// 2 & 3 are common in all 3 arrays.

sumCommon([1, 2, 2, 3], [5, 3, 2, 2], [7, 3, 2, 2]) ➞ 7
// 2, 2 & 3 are common in all 3 arrays.

sumCommon([1], [1], [2]) ➞ 0

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Words that Start with a Vowel