Odd test behavior - comment-out does not make test ignore lines

Tell us what’s happening:
The first test “You should remove the ES5 assignment syntax.” produces somewhat odd results, because it fails, when you comment out the ES5 code. You have to actually delete the characters to make it pass. Maybe that could be edited.

Would this be better as a GitHub issue? I have never created an issue …
https://github.com/freeCodeCamp/freeCodeCamp/blob/master/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.english.md

Your code so far


const HIGH_TEMPERATURES = {
yesterday: 75,
today: 77,
tomorrow: 80
};

// change code below this line

let { today, tomorrow} = HIGH_TEMPERATURES;

//const today = HIGH_TEMPERATURES.today;
//const tomorrow = HIGH_TEMPERATURES.tomorrow;

// change code above this line

console.log(yesterday) // should be not defined
console.log(today); // should be 77
console.log(tomorrow); // should be 80

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0.

Challenge: Use Destructuring Assignment to Extract Values from Objects

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects

Whenever regex is involved in the test, commenting out often doesn’t work.

I guess it would be possible to look for or account for, code comments in the regex. But that is just more work and likely to be more brittle.

It is best to assume that when a challenge says to delete something, it means delete. If it says to comment out something, it means comment out.

The test needs to return true to pass:

var code = 'const today = HIGH_TEMPERATURES.today;'
!code.match(/today = HIGH_TEMPERATURES\.today/g)
// false

var code = '//const today = HIGH_TEMPERATURES.today;'
!code.match(/today = HIGH_TEMPERATURES\.today/g)
// false

var code = '//const NOTtoday = HIGH_TEMPERATURES.today;'
!code.match(/today = HIGH_TEMPERATURES\.today/g)
// false

var code = '//const todayNOT = HIGH_TEMPERATURES.today;'
!code.match(/today = HIGH_TEMPERATURES\.today/g)
// true

var code = ''
!code.match(/today = HIGH_TEMPERATURES\.today/g)
// true
1 Like

We have a function that will strip the comments out of the editor code, so we should probably implement this on this particular challenge. I will create a PR now.