Created
July 6, 2022 15:24
-
-
Save izaakwalz/d3851a1659e7cb3ea895daeffd7ba43b to your computer and use it in GitHub Desktop.
algorithms challange
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assigment = {} | |
const myNumbers = [68, -68,27,94,72,-25,-51,32,10,64,-94,4,34,-86,90,81,20,-56,-91,-50] | |
function sumOfNumbers(arrayOfNumbers) { | |
return arrayOfNumbers.reduce((a,b) => a + b, 0) | |
// return arrayOfNumbers.length | |
} // chalange 1 | |
function countEvenNumbers(arrayOfNumbers = []) { | |
let count = 0 | |
for(let index = 0; index < arrayOfNumbers.length; index++) { | |
if (arrayOfNumbers[index] % 2 === 0) { | |
count++ | |
} | |
} | |
return count | |
} // challange 2 | |
console.log(assigment.countEvenNumbers = countEvenNumbers(myNumbers)) | |
console.log(assigment.sumOfNumbers = sumOfNumbers(myNumbers)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment