DEV Community

loading...

Discussion on: 5 ways to refactor if/else statements in JS functions

Collapse
cknott profile image
cknott

I think theres a typo in the last example of the 2nd block "OR operator"

this

  let sumFunctionWithOr = (a, b, inconsistentParameter) => {
    inconsistentParameter = inconsistentParameter ?? 0
    return a+b+inconsistentParameter
}
Enter fullscreen mode Exit fullscreen mode

should be

  let sumFunctionWithOr = (a, b, inconsistentParameter) => {
    inconsistentParameter = inconsistentParameter || 0
    return a+b+inconsistentParameter
}
Enter fullscreen mode Exit fullscreen mode
Collapse
sylwiavargas profile image
Sylwia Vargas Author

Ahhhh thank you! That's what happens when you copy examples mindlessly 😩