Spinal Tap Case Challenge


function spinalCase(str) {
  str = str.replace(/([a-z])([A-Z])/g, "$1 $2");
  return str.split(/\s+|_+/).join("-").toLowerCase();
}

I need help with what "$1 $2" means in the second line of the code above. That line of code was from the challenge guide.

Link to the challenge:

Link to the challenge guide

This challenge has it explained: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/use-capture-groups-to-search-and-replace

2 Likes

Thank you for your reply. It’s clearer now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.