Callback.apply is not a function

Choropleth challenge
The last 3 tests of the challenge, the tooltip ones, keep throwing an error ‘callback.apply is not a function’. Visually, I can see that the tooltip is working, but it simply won’t pass the tests because of the error. I tried rearranging the code so it no longer used a promise and callback, but the same situation happened with the tests, so I put it back to how it was.

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0

Challenge: Visualize Data with a Choropleth Map

Link to the challenge:

Well, an error “Uncaught TypeError: callback.apply is not a function…” tells me a few things.

It means that there was a type error. Something in JS has “thrown” an error. It is saying, “When I evaluate ‘callback.apply’, what I get is not a function.” Since all functions have the method “apply” that means that “callback” itself is not a function. It is probably undefined - just a guess.

When I open your project and look in the browser dev tools console, I see that that error is happening every time I mouseout - it has nothing to do with the test. I would examine that code closely and see if there is something going on there. The error also tells you what the d3 module is.

Thanks! The codepen console hadn’t flagged it and it didn’t occur to me to check the browser console. I changed .on('mouseout', tooltip.style('visibility', 'hidden')) to .on('mouseout', event => {tooltip.style('visibility', 'hidden')}) and it works fine now. :smile:

1 Like

Awesome. Yeah, the codepen console is sort of a fake console that intercepts some, but not all console information. Plus, in the dev tools there are a lot of cool things. I use the network tab all the time, and there are some really cool extensions for React and Redux.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.