Correct lesson input gives wrong results

I am on the lesson " Basic JavaScript: Stand in Line". All previous lessons worked fine. Now, with the correct input I get wrong results.


function nextInLine(arr, item) {
  // Only change code below this line
  return arr.shift();
  // Only change code above this line


// Setup
var testArr = [1,2,3,4,5];

// Display code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));

// running tests
nextInLine(, 5) should return a number.
nextInLine(, 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10) , testArr[4]
should be 10
// tests completed
SyntaxError: invalid regular expression flag s

Result should be:
Before: [1,2,3,4,5]
After: [2,3,4,5,6]

Seems to me the system is not working properly? Can you assist?

Welcome, richard.

The error that is printed comes from an issue some browsers have:
Error message in challenge console on initial page load: “SyntaxError: invalid regular expression flag s” · Issue #40311 · freeCodeCamp/freeCodeCamp (

The general consensus is to upgrade your browser version, if you see this error.

For future posts, if you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Also, I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

Thanks Sky020.

Problem solved - after I brought my Firefox browser up to latest version.

Also thanks for your guidance on posting a problem, etc. I’m a newbie to this forum so your input will be useful in future.

Thanks again.

1 Like