Search
 
SCRIPT & CODE EXAMPLE
 

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])
Comment

PREVIOUS NEXT
Code Example
Javascript :: cantsee auto complete for node jsmodules in vs code 
Javascript :: update button response 
Javascript :: element vs node 
Javascript :: svelte json 
Javascript :: find star index of string javascript 
Javascript :: react native carriage return 
Javascript :: cypher neo4j 
Javascript :: upload file javascript mdn 
Javascript :: toast duplicate angular 
Javascript :: remove undefined from object javascript 
Javascript :: Caret.editorconfig 
Javascript :: javascript paragraph class 
Javascript :: how to update a state with an array react 
Javascript :: save browser password 
Javascript :: React Hook "useState" is called in function "cardState" which is neither a React function component or a custom React Hook function 
Javascript :: javascript reflections iterate all members 
Javascript :: sessionStorage on DOMContentLoaded javascript 
Javascript :: unable to get local issuer certificate npm 
Javascript :: browser console unhide element 
Javascript :: asasa 
Javascript :: push code from vscode using CL 
Javascript :: momentjs isomonth 
Javascript :: jabascript for each 
Javascript :: remove null from object lodash 
Javascript :: multiple filter html table using javascript 
Javascript :: javascript channel flutter inappWebview 
Javascript :: call function on scroll down javascript 
Javascript :: how to make your own version of filter method 
Javascript :: js array map and update tat array value 
Javascript :: array loop 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =