Freecodecamp: [beta] D3 : "Identifier 'dataset' has already been declared" error

Created on 12 Nov 2017  ·  3Comments  ·  Source: freeCodeCamp/freeCodeCamp



Challenge Name


https://beta.freecodecamp.org/en/challenges/data-visualization-with-d3/change-styles-based-on-data

Issue Description


Going through the D3 challanges in beta, there are multiple ones that have always show the error "Identifier 'dataset' has already been declared." It appears to be a bug because the solution works if the const dataset line is commented out.

This happened on chrome. I checked and can't reproduce this error in Firefox quantum.

Browser Information

  • Browser Name, Version: Chrome 61.0.3163.100
  • Operating System: Windows 10 Pro
  • Mobile, Desktop, or Tablet: Desktop

Your Code



<body>
  <script>
    const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

    d3.select("body").selectAll("h2")
      .data(dataset)
      .enter()
      .append("h2")
      .text((d) => (d + " USD"))
      // Add your code below this line



      // Add your code above this line
  </script>
</body>


Screenshot


screenshot_1

help wanted learn

Most helpful comment

I tested this and a few other cases that use const dataset on later versions of Chrome (62 and 63) and got no errors.

All 3 comments

I tested this and a few other cases that use const dataset on later versions of Chrome (62 and 63) and got no errors.

I believe this issue has been fixed as part of this PR: #16149

Tests are now being executed in a fresh frame, which prevents the collision with the scope from previous run.

Yes, thanks a lot for confirming.

Was this page helpful?
0 / 5 - 0 ratings