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.

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

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
Johnny2136commented, Jul 24, 2018

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? 🐞

2reactions
ghostcommented, Aug 20, 2018

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>);

Read more comments on GitHub >

github_iconTop Results From Across the Web

ES6: Create Strings using Template Literals Bug - #22 by ilenia ...
Bug in ES6: Create Strings using Template Literals with Err Msg: Invalid regular ... I have the same problem too, it says Invalid...
Read more >
SyntaxError: invalid regular expression flag "x" - MDN Web Docs
The JavaScript exception "invalid regular expression flag" occurs when the flags in a regular expression contain any flag that is not one of:...
Read more >
Can ES6 template literals be substituted at runtime (or reused)?
To make these literals work like other template engines there needs to be an intermediary form. The best way to do this is...
Read more >
API - esbuild
This API call is used by the command-line interface if no input files are provided and the --bundle flag is not present. In...
Read more >
Using ES6 template strings for regular expressions - 2ality
ECMAScript 6 template strings [1] give us multi-line raw (backslash has no special meaning) string literals and interpolation.
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