Keyword vs Console.log in Fuctions!


#1

Why Is It Necessary to use return keyword in a function other than loging into console using "console.log" method


#2

Logging only outputs. When we wish to hand processed data back to the calling scope we return it. That way we can store the result and use it in further processing.

var is_even = function (number) {
    return number % 2 === 0;
};

var num = 42;
if (is_even(num)) {
    console.log(num + "is even";
}

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.