Back to all solutions
#1085 - Sum of Digits in the Minimum Number
Problem Description
Given an integer array nums, return 0 if the sum of the digits of the minimum integer in nums is odd, or 1 otherwise.
Solution
/**
* @param {number[]} nums
* @return {number}
*/
var sumOfDigits = function(nums) {
const digitSum = Math.min(...nums)
.toString()
.split('')
.reduce((sum, digit) => sum + parseInt(digit), 0);
return digitSum % 2 === 0 ? 1 : 0;
};