JavaScript JavaScript Unit Testing Improving Our Tests Catching an Error

Ioannis Leontiadis
Ioannis Leontiadis
9,828 Points

Catching an Error?

Hello,

I was wondering how this challenge is set up. Changing the handler function from let to var did the magic.

let handler = function() { /*code*/ };
expect( handler ).to..

changed to,

var handler = function() { /*code*/ };
expect( handler ).to..

Is this something treehouse specific? Tests seem to run as expected in a local machine environment.

Thank you in advance.

1 Answer

Rich Zimmerman
Rich Zimmerman
24,062 Points

I could be wrong, but since the difference between const and let is that const makes a variable immutable. So i would think you do not want to declare a function with 'let' because you don't want to change what a function does after it's declared. that could cause some weird errors..