Stand in Line: Javascript

What am I missing in the below? The code works as expected/

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

// Setup
let 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));

I’ve edited your code 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

Is this a curriculum challenge? If so, always post a link to the challenge.

It works as expected? If it’s failing tests, then it is decidedly not working as expected. It may work the way you expect it to work, but that is not always the measure.

Just looking at your code… You are passing in an array to your function. Think about that. Why are we passing in an array? Are you utilizing that correctly?

1 Like

change your testArr to just arr

1 Like

thank you so much ! I missed the obvious.

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