Heatmap FCC Test Issue

The json data has months ranging from 1 to 12, so I built around that range.
But I’m getting this error:
“data-month should be at most 11: expected 12 to be at most 11
AssertionError: data-month should be at most 11: expected 12 to be at most 11”
and previous to that I was getting … “should be at least 0: expected nan to be at least 0”
But my months are within range of the json data. I saw no need to change the month values to a 0 to 11 range.

In order to get it to pass the test for “data-month” property/attr, I had to do .attr("data-month", d => d.month - 1)

which leads me to kindly say:

I believe shouldn’t have been necessary because this particular test-suite test should have been geared toward the json month data or allow for a 1 to 12 month range input too.

But, I’m still learning and improving in coding and maybe y’all have a good reason for that, but if so, I’d like to hear why. :slight_smile:

Here’s my unrefactored codepen I’m still working on: https://codepen.io/nwbnwb/pen/eYzOqRV?editors=0010

Hello there,

I am seeing the tests error out, because of this line ~220

.on("mouseover", () => d3.select(this).attr("fill", "purple"))

There seems to be an issue with the type of this

Opening the browser console reveals more.

I just commented out that code containing “this” and changed .attr("data-month", d => d.month - 1) to .attr("data-month", d => d.month) and the error popped back up.

Right. Thank you, for the clarification.

For the most part, I agree, but will leave for others to weigh in.

Perhaps the only reason is JavaScript (thus, consequently the DOM) is 0 indexed. So, it could be argued that it is bad-practice to use anything else. To add, this applies to something like months, because even JS’s date object returns months 0-based.

I was thinking that may be their reasoning for it as well. Have a great day Sky020 .