swati-jagtap / javascript-practice

0 stars 0 forks source link

7.2.14 Write a function which takes any number of arguments and return the sum of the arguments #84

Open swati-jagtap opened 3 years ago

swati-jagtap commented 3 years ago

7.2.14 Write a function which takes any number of arguments and return the sum of the arguments

function anyArgument()
{
    let sum=0;
    for(let i=0;i<arguments.length;i++)
    {
        sum+=arguments[i];
    }
    return sum;
}    
console.log(anyArgument(10,20,30,40));
console.log(anyArgument(1,22,30,4))

output

image