This is what i found about this problem

function nextInLine(arr, item) {
  // Only change code below this line
  if(arr.length == 0){


  	arr[0] = item;
  	newArr = arr[0]
  	return newArr;
  }
  newArr = arr[0];
  arr.push(item);
  arr.shift(arr);
  return newArr;
  // Only change code above this line
}

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

this is the result

hope this can help you :grinning:

1 Like

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 (').

And since this is a working solution, I added [spoiler][/spoiler] tags.

Cool, we’re glad that you solved it. (Although I had to make a small change to get it to work for me.)

We don’t usually post working solutions, especially for curriculum problems. Remember that there are other learners here, testing also. If you were in school, in the middle of a test, you wouldn’t go up to the blackboard and start writing out the answers.

Were you looking for some critique?