question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSRemoveComments Causing Test to Fail

See original GitHub issue

Lesson: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/use-higher-order-functions-map-filter-or-reduce-to-solve-a-complex-problem

This code fails one particular test:

const squareList = (arr) => {
// Only change code below this line
return arr
  .filter(num => num > 0 && Number.isInteger(num))
  .map(num => Math.pow(num, 2));
// Only change code above this line
};

const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers);

Whereas, if the spaces to the left of .map or .filter are removed, the code passes.

Helper Function: https://github.com/freeCodeCamp/freeCodeCamp/blob/master/client/src/utils/curriculum-helpers.js

MD File: https://github.com/freeCodeCamp/freeCodeCamp/blob/master/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-higher-order-functions-map-filter-or-reduce-to-solve-a-complex-problem.md

@RandellDawson pinging

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ShaunSHamiltoncommented, Nov 14, 2020

I honestly do not see a need to combine the two functions, but that is just me.

I thought the reason is to resolve this issue - removeJSComments by itself causes unwanted formatting.

But I have just thought of why removing whitespace is not the best solution, because JS keywords rely on whitespace for delimanation. Probably works for most tests, but can cause other issues down the line.

0reactions
ShaunSHamiltoncommented, Feb 10, 2021

I am going to close this, for now.

Reason: The specific challenge mentioned does not experience this, anymore, and is/was AFAIK the only one experiencing any issue with removeJSComments. So, unless this pops up again in new challenges, nothing will need to be done here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Comments in test file throws exception when writing inline ...
Bug Report When a test file has comments has empty toMatchInlineSnapshot() Running jest will fail when prettier tries to prettify the file ...
Read more >
How to strip comments in javascript? - node.js - Stack Overflow
I think strip comment is not working because it takes string as an argument but fs.readFileSync doesn't return string. I have also tried...
Read more >
Code Review: Please Remove Comments From Your Code
These days, I usually ask other people to remove mostly all their comments in code review. This post will talk about the reason...
Read more >
Is there a method for differentiating informative comments from ...
There is a very simple solution to this: remove the commented-out code. Really, there are only two good reasons to comment out code:...
Read more >
Ticket: Create/ Update/ Delete comments - M220JS - MongoDB
I m stuck on the Update and Delete comments ticket. I believe my code is correct and I am passing 2/3 tests, however,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found