DEV Community

Discussion on: Understanding JavaScript Functions

Collapse
 
budisalah profile image
Budi Salah 🐋 • Edited

Hey @frugencefidel , Thank you for this cool demonstration.
I just noticed an error in your code in Default Function Arguments section.

function sum(a = 5, b = 7) {
  return a + b;
}

// If all arguments are undefined, then pass nothing
console.log(sum()); // 12

// If all arguments are not undefined
console.log(sum(6, undefined)); // 12
Enter fullscreen mode Exit fullscreen mode

The last expression should output 13 not 12

// If all arguments are not undefined
console.log(sum(6, undefined)); // 13
Enter fullscreen mode Exit fullscreen mode

Thank you for your time. 💖

Collapse
 
frugencefidel profile image
Frugence Fidel

Thanks for that buddy. I will fix it soon