Can't solve stand in line

the link of challenge is : https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/stand-in-line

this is my code

function nextInLine(arr, item) {
  // Only change code below this line
  nextInLine([6, 5, 8], 1);
  arr.push(item);
  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));

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

What issues are you having with your code? What do the failing tests say?

Why are you calling nextInLine() from within nextInLine() with hardcoded values?

I called the function inside the function because comments said to only to change inside those range

it’s showing this in the output

Before: [1,2,3,4,5]
RangeError: Maximum call stack size exceeded

You’re creating infinite recursion and causing a crash.

I still don’t understand why you’re calling the function recursively.

well I thought I could call them inside the function .After this reply I tried to call the function outside the function then I completed the challenge. Thanks for your helpful reply. I didn’t understand the recursive stuff yet I guess I did it without knowing it.