JSFiddle - React, Tailwind, and code Playground

by Ryan Brackett

JavaScript

// The values for my_numbers are given when I click "Run"

export function find_total(my_numbers) {
  var result = 0;
  my_numbers.map(
    function(value) {
      //Add 1 point if even number
      if (value % 2 === 0) {
        result = result + 1;
      }
      //Add 3 points if odd number
      if (value % 2 !== 0 && value !== 5) {
        result = result + 3
      }
      //Add 5 points for 5
      if (value === 5) {
        result = result + 5
      }
    }
  );
  return result;
}