Answers for "exit a function in javascript"

0

exit a function in javascript

//javascript exit function using return
function add(a, b) {

    // if a and b is empty then exit the function
    if (!a && !b) {
        return;
    }

    return a + b;
}


console.log(add(1, 3));
// 4

console.log(add());
// undefined
Posted by: Guest on October-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language