Skip to content

Instantly share code, notes, and snippets.

@pinchez254
Last active November 27, 2022 23:14
Show Gist options
  • Save pinchez254/487088c6b399a5f8b617b1ec9627e0ef to your computer and use it in GitHub Desktop.
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
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