Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sum the two first minimum numbers in an array

function sumTwoSmallestNumbers(numbers){
    function sortNumber(a , b){
        return a - b
    }
    numbers.sort(sortNumber)
    // console.log(numbers)
    return numbers[0] + numbers[1]
}
// sumTwoSmallestNumbers([5, 8, 12, 19, 22])
sumTwoSmallestNumbers([15, 28, 4, 2, 43])
 
PREVIOUS NEXT
Tagged: #sum #minimum #numbers #array
ADD COMMENT
Topic
Name
7+3 =