JavaScript Program to Set a Default Parameter Value For a Function Full Project For Beginners

 

 

script.js

 

 

// program to set default parameter value

function sum(x = 3, y = 5) {

    // return sum
    return x + y;
}

console.log(sum(5, 15));
console.log(sum(7));
console.log(sum());

Leave a Reply