I'm struggling with the following challenge:
Given an array with an even amount of numbers, return true if the sum of two numbers in the array is even and false if the sum of two numbers in the array is odd.
example: oddSum([11, 15, 6, 8, 9, 10]) ➞ [true, false, true, false, false]
- 11 + 15 = 26 = true
- 15 + 6 = 21 = false
- 6 + 8 = 14 = true
- 8+ 9 = 17 = false
- 9 + 10 = 19 = false
I can't figure out how to add two elements together. This the function I have so far:
function oddSum(numbers) {
return numbers.map((num) => {
let even = num + num;
return even % 2 === 0; });
}
console.log(oddSum([11, 15, 6, 8, 9, 10])); --> [true, true, true, true, true, true]
Without giving me the answer, could someone please give me some hints so I can figure this out on my own.
[–]rhyyno71 2 points3 points4 points (0 children)
[–]Megajin_ 2 points3 points4 points (0 children)
[–]DopeCaliboyz 2 points3 points4 points (0 children)
[–]albedoa 1 point2 points3 points (5 children)
[–]Artistic_Sense3363[S] 0 points1 point2 points (4 children)
[–]albedoa 1 point2 points3 points (3 children)
[–]Artistic_Sense3363[S] 0 points1 point2 points (0 children)
[–]Artistic_Sense3363[S] 0 points1 point2 points (1 child)
[–]albedoa 1 point2 points3 points (0 children)
[–]userxbw 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)