How to pass an array to a function with parameter for each array value in Node.js

1 Answer

0 votes
function sum(n1, n2, n3, n4, n5, n6) {
    return n1 + n2 + n3 + n4 + n5 + n6;
}
 
const arr = [34, 2, 9, 1, 8, 70];
 
console.log(sum(...arr)); 
 
 
 
 
/*
run:
 
124
 
*/

 



answered Dec 18, 2021 by avibootz
...