Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,063 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..