I need help please!!!. I tried the summary calculator and there is a "undefined" between the outpout , how to remove it? | Sololearn: Learn to code for FREE!

0

I need help please!!!. I tried the summary calculator and there is a "undefined" between the outpout , how to remove it?

function Add(...num){ var sum = 0; for(l=0; l<num.length; l++){ sum = sum + num[l]; } console.log(sum) } console.log(Add(1,2,3)); console.log(Add(4,14,5,9,14)); console.log(Add(2,36));

9/3/2021 3:33:58 PM

Harena

4 Answers

New Answer

+4

return sum

+1

Instead of writing console.log(sum) Write return sum It means whenever u call Add function sum will return

+1

Thank you everyone , i just solved it after i posted this 😅😅😅

0

Hey, could you paste that into a code bit and link it here? Makes it easier for all of us thank you ^^