question archive Hey, how should I code a function that accepts an array and a number

Hey, how should I code a function that accepts an array and a number

Subject:Computer SciencePrice: Bought3

Hey, how should I code 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 in JavaScript?

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE