AI

Arrow functions () => {} behave differently than regular functions. They don't have their own this; they inherit it from the surrounding scope.

Your Task:

  • We have a target object with a score
  • Inside shootArrow, this.score works because it's a normal function
  • But inside setTimeout, a normal function would lose this. Use an arrow function inside setTimeout so it keeps looking at the target object.
  • Update score to 100 inside the callback
TypeScript Solution
Loading...

Submit your code to see test results