Insufficiently free regex (Data Structures - Learn how a Stack Works)

Tell us what’s happening:

The current regex for the “The initial declaration of the homeworkStack should not be changed.” condition is not permissive enough to allow certain code styles, and I suggest that it be changed to /homeworkStack\s*=\s*\[\s*(["'])BIO12\1\s*,\s*(["'])HIS80\2\s*,\s*(["'])MAT122\3\s*,\s*(["'])PSY44\4\s*,?\s*\]/ instead.

Specifically, the new regex would permit the following refactory changes:

  • Usage of single quotes
  • Multiline declaration of the array
  • A trailing comma

I’m aware that this is quite nitpicky, but it bothered my OCD too much.

Your code so far

const homeworkStack = [
  "BIO12",
  "HIS80",
  "MAT122",
  "PSY44",
];

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0

Challenge Information:

Data Structures - Learn how a Stack Works

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