Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript Default Parameters

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

    // return sum
    return x + y;
}

console.log(sum(5, 15));  // 20 
console.log(sum(7));        // 12
console.log(sum());          // 8
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #JavaScript #Default #Parameters
ADD COMMENT
Topic
Name
3+1 =