Assigning functions to variables in JavaScript
So, we have already found out that the name of the function and its source code are separated from each other. Therefore, in JavaScript there is an alternative syntax for creating a function: a function is created without a name and assigned to some variable. This variable becomes the name of the function.
Let's look at an example:
let func = function() {
console.log('!');
};
func(); // shows '!'
Make an anonymous function that will
return the number 1 via
return. Write this function
to the variable func1.
Make an anonymous function that will
return the number 2 via
return. Write this function
to the variable func2.
Find the sum of the values of the
functions func1 and func2.
Print this sum to the console.