ES6: Create Strings using Template Literals Bug

ES6: Create Strings using Template Literals Bug
0

#1
const result = {
  success: ["max-length", "no-amd", "prefer-arrow-functions"],
  failure: ["no-var", "var-on-top", "linebreak"],
  skipped: ["id-blacklist", "no-dup-keys"]
};
function makeList(arr) {
  "use strict";

  const [a,b,c] = arr;
  const resultDisplayArray = [
    `<li class="text-warning">${a}</li>`,
    `<li class="text-warning">${b}</li>`,
    `<li class="text-warning">${c}</li>`
  ];

  return resultDisplayArray;
}

const resultDisplayArray = makeList(result.failure);

This is my solution and it’s correct but freecodecamp says Invalid regular expression flags ;/
Lost 2 hours on this challenge before realizing its a bug… please fix it

BTW I GOT BANNED FOR THIS POST. Good job fcc team!


#2

Hello Johnny,

Ues sounds like an issue with regex, thansk for the report.

I will open an issue on FCC github page later if there is no any similar issue already(you can do it too)

Thanks for the report. Keep going on great work, happy programming.

EDIT:
This issue already addressed and you great people would wait for an update soon to get it work soon.


#3

The solution posted by JohnnyDevX doesn’t include any backticks - this may be the cause of the ‘bug’ but can’t verify that.


#4

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#5

There is a known bug in this challenge. I don’t know if it has been fixed yet, but you might fail anyway because you shouldn’t hard-code those replies in there like that. What if they wanted to send you an array with 2 or 4 strings? You should be using a for loop, or even better the map function.


#6

I have the same problem too, it says Invalid regular expression flags. here is my code:
const result = {
success: [“max-length”, “no-amd”, “prefer-arrow-functions”],
failure: [“no-var”, “var-on-top”, “linebreak”],
skipped: [“id-blacklist”, “no-dup-keys”]
};
function makeList(arr) {
“use strict”;
// change code below this line//
const resultDisplayArray=[];
for( let i=0; i<result.failure.length;i++){
resultDisplayArray.push(<li class="text-warning">${result.failure[i]}</li>);
}
// change code above this line

return resultDisplayArray
}
console.log(makeList());
const resultDisplayArray=makeList();


#7

The bug must be something to do with the backticks (``), I have them in my code but there were no backticks in my post too.


#8
```<p>Have a good weekend</p>

#9

Yes, backticks are used in markup to delineate code. If you put three backticks on the line before and after, it’s a code block. For inline code you use one before and after. So, without the enclosing three ticks, it saw your template literal as an inline code block and didn’t display the backticks.


#11

Yes, I know and I made it the correct way before, but then I thought that the loop or map might be the reason if issues so I created it most simply possible. No solution is correct for this challenge.


#12

Hey fellow code campers,

I’m having the same problem. Stuck on this challenge and unable to proceed because the challenge doesn’t seem to recognize that I’ve put in a template string in the code - therefore no solution is currently passable.

Here’s a screenshot as I think this helps:

I ran this is Visual Studio Code and it recognizes the template string, so I know the code is correct.

Any suggestions or ways for us to move onto the next challenge so those of us who are stuck can continue? Or best to simply wait for them to fix this? Appreciate all the help.

Here is the visual studio screenshot:


#13

yeah bro, and the next subject after ES6 is Regular Expressions…
what even more funny the next one is debugging!

I don’t really know if I want learn regex and debugging from people who can’t write regex and TEST if their solution test works or not…


#14

As I said, there was a bug on the challenge that was being addressed. Just move on - you can come back to it later.


#15

Consider that the camp software is an open source project and that FCC campers are even encouraged to participate. Chances are good that the person that wrote the test code is a fellow camper or a former camper and likely unpaid for their work.

Also consider that crafting test code that accounts for any number of possible valid solutions while disallowing any cheats or shortcuts is a hellalot harder than just coming up with a solution to a challenge.

The camp got a major overhaul recently with old challenges being reworked and many new challenges added. There was a beta testing period but any bugs that surfaced afterward are being dealt with as quickly as possible. This is one of those recent bugs - the code was updated to be more lenient on the white space in various solutions and that unfortunately introduced a bug.

In spite of the bugs I still feel like I got my money’s worth out of FCC.


#16

@alhazen1 FCC is doing a great job, appreciate them creating this class structure for us.
@kevinSmith Thanks, I didn’t realize I could simply skip over the lesson. For anyone else who got stuck, click on curriculum and go back to the course list and then choose the next lesson.


#17

all true things but I get the feeling whoever submitted the fix did not run the required unit-tests (test buckets) that are needed. Pretty sure the test buckets would have caught it. If not , the test bucket needs an update. (my reasoning is that the code fails in every solution. Not just some. And that suggests it was not tested at all)


#18

Just bumping in here to say that I’m stuck on this for the same reason. FWIW I think the instructions could use some clarification. I tried back ticks around the entire array at first. Does this technique produce strings? If not, why would back ticks around the whole array not be just as good? If so, (which I think is the case), then the description in the code of what the expected output should be is incorrect, as each portion of the returned array would be a string with ‘’ or “” around it.


#19

Yep - I get the same problem


#20

I suggest posting a new question with your code details and questions rather than adding onto this thread. Or even better, just look at related posts made by ithers for additional help first.


#21

Thank you, option 1 work fine without any error.

I don’t really understand the second option. I does the code iterate within result.failure