Question: // JavaScript console.log(Script has arrived); // Write code according to the comments below. console.log(-------------- First-Class Functions ---------------) // write a normal named function definition that

// JavaScript

console.log("Script has arrived");

// Write code according to the comments below.

console.log("-------------- First-Class Functions ---------------")

// write a normal named function definition that takes two numbers and returns the sum

function f(n1, n2)

{

return n1 + n2;

}

// declare a variable and assign it that function

let v = f;

console.log(f(8, 7) + v(15, 9));

// call the function through the variable and print the result

// write an anonymous version of the same function using the "function" syntax

// call it and print the result

let myFun = function(a, b, c)

{

return a + b - c;

}

myFun(1, 2 ,3);

// write a => version of the same function (still using {} and return)

// call it and print the result

let myFunc = (a, b ,c) => {return a + b + c; };

let myFunct = (a, b ,c) => a + b + c;

let acutal;

/* write a => version of the same function (with an expression body instead)

call it and print the result */

/* write a => function that takes a string and return another => function that prints that string

the internal function should *not* take the string as a parameter, since the variable is

already in scope */

//call the initial function to get the callback, then call that to print the string

// write and call a => function that takes a string and uses setTimeout to print that

// string 1000ms later

console.log("this script is done")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!