swati-jagtap / javascript-practice

0 stars 0 forks source link

7.3.11--Call your function sum, it takes any number of arguments and it returns the sum. #71

Open swati-jagtap opened 3 years ago

swati-jagtap commented 3 years ago

7.3.11--Call your function sum, it takes any number of arguments and it returns the sum.

function sum()
{
    var s=0;
    for(let i=0;i<arguments.length;i++)
    {
        s+=arguments[i];
    }
    return `sum of ${arguments.length} arguments is ${s}` ;
}
console.log(sum(1,2,3,4,5));
console.log(sum(12,20,3));`

output

image