Writing a function to another variable in JavaScript
Let we have our function func
:
function func() {
console.log('!');
}
Let's copy its source code into
the variable test
:
function func() {
console.log('!');
}
let test = func; // now test is the same function as func
// Let's check:
test(); // shows '!'
func(); // shows '!'
Make the function func1
that
will return the number 3
via return
.
Copy the source code of the function
func1
into the
variable func2
.
Print to the console the sum of the
results of the functions func1
and func2
.