Animal Fun Facts: Normal Function vs. Arrow Function

I recently finished the Animal Fun Facts project. I got stuck for a long time because displayFacts would not work when assigned, and I eventually found that it was because of my function definition. I had initially defined it as an arrow function as follows:

const displayFacts = e => {...};

Eventually I corrected it to:

function displayFacts(e) = {...}

This seemed to fix it, which leads me to my question.

Why did this not work with an arrow function?

My first guess is that fails in the same way that the “this” keyword works differently in arrow functions, but I’m really not sure, and googling didn’t help very much.

See this post:

1 Like

Yes! This is exactly correct. I just tried shifting the order to have the definition with an arrow function before the call during the for loop, and the error went away. Thanks for the quick reply!

1 Like