Summing integers greater than or equal to 10

Given an array of integers, this function will return the sum of the integers that are greater than or equal to 10.

Problem

Given an array of integers, return the sum of the integers that are greater than or equal to 10.
Example input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
Example output: 75

Solution

This solution is in JavaScript. Our A.I. can create solutions in multiple languages.
by kayakane
// Solution:

function sumOfTen(arr) {
  let sum = 0;
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] >= 10) {
      sum += arr[i];
    }
  }
  return sum;
}

// This solution is optimal because it uses a for loop to iterate through the array and check if each element is greater than or equal to 10. If it is, it adds it to the sum. This solution is optimal because it is simple and easy to understand.

A.I. Evaluation of the Solution

This solution is correct and solves the problem. The approach is simple and easy to understand.

Evaluated at: 2022-11-26 00:16:29