Spinal Tap Case test passes in Chorme but not Firefox

Tell us what’s happening:
Title sums the issue. Using Chrome code passes the test, but in Firefox it fails with the message: invalid regexp group.

Could some one explain why?

Your code so far


function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  var regex = /(?<=[a-zA-Z])[A-Z]/g;
  return str.replace(regex, "-$&").toLowerCase().replace(/[_\W]/g, "-");
}

spinalCase('This Is Spinal Tap');

Your browser information:

User Agent is: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/spinal-tap-case/

Firefox does not currently support positive lookbehind.

1 Like