Changing variable name makes tests fail

All is good when callback argument is called data.
Changing the name of the variable to anything other than data makes tests fail.

Changing the response argument name does not fail tests.
It may be a buggy behavior.


<script>
document.addEventListener('DOMContentLoaded',function(){
  document.getElementById('getMessage').onclick= () => {
    // Add your code below this line
  fetch('/json/cats.json')
    .then(response => response.json())
    .then(d => {
      document.getElementById('message').innerHTML = JSON.stringify(d);
    })

    // Add your code above this line

Challenge: Get JSON with the JavaScript fetch method

Link to the challenge:

There are regex checks in the tests that are looking for data. I’m sure the tests can be unconstrained to allow for anything for the callback parameter.

If you want you can open an issue for it. Or create a PR with a fix.


Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

Thank you, for pointing this out. It is definitely not a well-made test:

assert(code.match(/\.then\s*\(\s*(data|\(\s*data\s*\))\s*=>\s*{[^}]*}\s*\)/g));

I have opened an issue on it: "Get JSON with the JavaScript fetch method" Test Too Specific · Issue #41750 · freeCodeCamp/freeCodeCamp · GitHub