Last active
November 27, 2022 23:14
-
-
Save pinchez254/487088c6b399a5f8b617b1ec9627e0ef to your computer and use it in GitHub Desktop.
Given an array of integers, keep a total score based on the following; 1. Add 1 point for every even number in an array. 2. Add 3 points for every number in the array. 3 Add 5 points for every time you encounter 5 in the array. leave a star if this helped you
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
export function find_total( my_numbers ) { | |
//Insert your code here | |
let score = 0 | |
my_numbers.forEach((x)=>{ | |
if(x%2==0){ | |
score = score + 1 | |
}else if(x % 2 != 0 && x !== 5){ | |
score = score + 3 | |
}else{ | |
score = score + 5 | |
} | |
}) | |
return score | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment