freeCodeCamp: Bug in ES6: Create Strings using Template Literals with Err Msg: Invalid regular expression flags

Describe your problem and - if possible - how to reproduce it

The Challenge, ES6: Create Strings using Template Literals, return an error message Invalid regular expression flags.

My solution is,

arr.map(a=>`<li class="text-warning">${a}</li>`);

where the console log shows the correct solution,

["<li class="text-warning">no-var</li>", "<li class="text-warning">var-on-top</li>", "<li class="text-warning">linebreak</li>"]

And the full code is,

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 = arr.map(a=>`<li class="text-warning">${a}</li>`);
  // change code above this line

  return resultDisplayArray;
}
/**
 * makeList(result.failure) should return:
 * [ <li class="text-warning">no-var</li>,
 *   <li class="text-warning">var-on-top</li>, 
 *   <li class="text-warning">linebreak</li> ]
 **/
const resultDisplayArray = makeList(result.failure);
console.log(resultDisplayArray);

Add a Link to the page with the problem

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals

Tell us about your browser and operating system

  • Browser Name: Chrome
  • Browser Version: Version 67.0.3396.99 (Official Build) (64-bit)
  • Operating System: Win10

If possible, add a screenshot here

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 10
  • Comments: 27 (4 by maintainers)

Most upvoted comments

Still buggy… My solution, (though I tried the looping solution and some listed above) No luck

// change code below this line
  const resultDisplayArray = arr.map(obj => `<li class="text-warning">${obj}</li>`);
// change code above this line

yeilds:

// running test
Invalid regular expression flags
// tests completed

I hate leaving assignments undone, does anyone have a workaround? 🐞

This works for me for today: 21-08-2018 No Bugs for: template strings were used const resultDisplayArray = arr.map(err => <li class="text-warning">${err}</li>);

this was driving me mad even tho my solution was correct i even copied one of solutions and still no hope lol

Hi all, thank you for reporting this and coming up with different solutions. You’re right, this is a recent problem that was caused by updating the regex to account for different solutions, but unfortunately we didn’t escape that last forward slash. This was fixed recently and will hopefully be on the production site soon.

I’m going to close this for now, but please comment if you still have this issue after the fix rolls out.

Still getting the same error while my code is right. Kindly fix the bug.

@scissorsneedfoodtoo When will the fix roll out? Just to let you know it keeps showing the same error for my solution too: const resultDisplayArray = arr.map(el => `<li class="text-warning">${el}</li>`);