Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

=+ How can they be incorporated into social media content?

Answered: 1 week ago