Question

What would the result be if you ran the following code: function makeAdder(x) { return function(y)...

What would the result be if you ran the following code:

function makeAdder(x) {
return function(y) {
    return x + y;
};
}
var add8 = makeAdder(8);

var add12 = makeAdder(12);

console.log(add8(4));

console.log(add12(5));

0 0
Add a comment Improve this question Transcribed image text
Answer #1

12
17


Add a comment
Know the answer?
Add Answer to:
What would the result be if you ran the following code: function makeAdder(x) { return function(y)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Which of the following replacement code fragments will fix the code below? console.log(square); console.log(square(5)); var square...

    Which of the following replacement code fragments will fix the code below? console.log(square); console.log(square(5)); var square = function(n) {   return n * n; } A.) alert(square); alert(square(5)); var square = function(n) {   return n * n;  } B.) console.log(square); console.log(square(5)); var function square = function(n) {   return n * n;  } C.) console.log(square); console.log(square(5)); function square = function(n) {   return n * n;  } D.) console.log(square); console.log(square(5)); function square(n) {   return n * n;  }

  • QUESTION 1 What will be displayed as a result of executing the following code? int   x...

    QUESTION 1 What will be displayed as a result of executing the following code? int   x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points    QUESTION 2 What will be the displayed when the following code...

  • how is this solves? function looping(x,y){ for(var i=0; i<x; i++){ for(var j=0; j<x; j++){
    console.log(i*j);...

    how is this solves? function looping(x,y){ for(var i=0; i<x; i++){ for(var j=0; j<x; j++){
    console.log(i*j); } } } z = looping(3,3); console.log(z);

  • Look at the following function definition: def my_function(x, y): return x[y] a. Write a statement that...

    Look at the following function definition: def my_function(x, y): return x[y] a. Write a statement that calls this function and uses keyword arguments to pass ‘testing’ into x and 2 into y. b. What will be printed when the function call executes? 6. Write a statement that generates a random number in the range I'm using python to solve this this is what i did def main():      result= my_function(x='testing', y=2)      print(result) def my_function(x,y):      return x[y] main()

  • A C function fun has the following code body: *p -d; return x-c; The IA32 code implementing this ...

    A C function fun has the following code body: *p -d; return x-c; The IA32 code implementing this body is as follows 12 (%ebp) ,%eax 16(%ebp) , movabl nov1 nov1 %edx ,(%eax) movsw1 8(%ebp),%eax movl 20 (ebp), %edx subi %eax,%edx movi %edx, %eax 2 %eax 4 7 Write a prototype for function fun, showing the types and ordering of the arguments p, d, x, and c. A C function fun has the following code body: *p -d; return x-c; The...

  • 2. What is the value of x alter the following code is executed # include<iostream> using...

    2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...

  • I need to rewrite this code without using lambda function using python. def three_x_y_at_one(x): result =...

    I need to rewrite this code without using lambda function using python. def three_x_y_at_one(x): result = (3 * x *1) return result three_x_y_at_one(3) # 9 zero_to_four = list(range(0, 5)) def y_values_for_at_one(x_values): return list(map(lambda x : three_x_y_at_one(x), x_values)) -------> this is the function that I need to rewrite without using a lambda function . y_values_for_at_one(zero_to_four) # [0, 3, 6, 9, 12] Thanks

  • 8. (10%) Consider the following JavaScript program: // The main program var x,y; function f10{ var...

    8. (10%) Consider the following JavaScript program: // The main program var x,y; function f10{ var y, z; function f20{ var x, Z, P; function f30{ var x, z, ; Assume that the execution of this program is in the following unit order: main calls f3, f3 calls f1, f1 calls 12. a) Assuming that static scoping is in effect, indicate which version of each of the following variables will be visible in f2 by filling in each blank with...

  • def max_of_two( x, y): ifx>y: return x returny a. Write a Python function called max_of_three( x,...

    def max_of_two( x, y): ifx>y: return x returny a. Write a Python function called max_of_three( x, y, z ) to return the largest numbers of three numbers passing to the function You can use the function max_of_two in your solution. /Your code

  • 1. var s = "A red boat"; var a = s.split(" "); what is the value...

    1. var s = "A red boat"; var a = s.split(" "); what is the value of a? var b = [9, 3, 2, 1, 3, 7]; var c = b.slice(2, 5); What is the value of c? var d = c.concat(a); alert(d.join("**")); [ 'A', 'red' , 'boat'] [ 2 , 1, 3] 2**1**3**A**red**boat [ 'A', 'red' , 'boat'] [ 1 , 3, 7] 8**A**red**boat [ 'A', 'red' , 'boat'] [ 3 , 2, 1] A**red**boat [ 'A', 'red' ,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT