...

/

Exercise on Tail Call Optimization & other Function Features

Exercise on Tail Call Optimization & other Function Features

In the following exercises, you will use tail call optimization, create a stack, and examine how new.target behaves in ES5.

Exercise 1:

Implement a stack in ES6. In addition to a constructor, it should have a push(), pop(), and a len() function that would return the number of elements in the stack.

Press + to interact
class Stack {
//Write your code here
}

Exercise 2:

Write a tail call optimized solution for the following Fibonacci function. See if all of the tests work after you tail-call optimize the given function. Remember to name your function fib2() or the tests won’t ...