Ok i dont understand

Tell us what’s happening:
i have put in the code in different ways even looked at the hint option and tried to even look at other posts about it im stuck and getting nowhere and i dont want the answer handed to me i just wanna understand it better and do it on my own.

Just show us your code, the challenge you’re stuck on, and we can help ya out (without just giving you the answer).

3 Likes

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.

Thank you.

1 Like
function nextInLine(arr, item) {

  // Only change code below this line

  

  return item;

  // Only change code above this line

  arr.push(item);

  return arr.shift();

}

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

this what i have i dont know if im missing something or dont understand something

Your code works, but the order seems to be whats wrong. When a function is called it goes through each line of code you write, top to bottom. So in order the function you wrote in the code you gave reads :

function nextInLine(arr, item) {
   // first > return item;
   // second > arr.push(item);
   // third > return arr.shift();
}

The lesson also tells you to only change code on a specific set of lines. If you deviate from that, you might put your code in the wrong order.

Hopefully this can help ya figure out the problem!

2 Likes

thanks ill check it and see if that helps

1 Like

i fixed it and passed it.

2 Likes

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