question archive Hey, how do I code in JavaScript a function that accepts an array and a number

Hey, how do I code in JavaScript a function that accepts an array and a number

Subject:Computer SciencePrice: Bought3

Hey, how do I code in JavaScript a function that accepts an array and a number. The function would start summing the values of array until the sum is greater or equal to the number passed to the function as second argument. The function would then return the valuefunction([5,1,2, 4],6) //returns 6function([5,1,2, 4],8) //returns 8

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE