I need the complete solution for this........thanks!

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function nextInLine(arr, item) {
// Only change code below this line
arr.push(6);
arr.shift(1);

return item;
// 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));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55

Challenge: Stand in Line

Link to the challenge:

Please describe your issue here.

Note that we are not a code writing service. We help you fix your work; we don’t do the work for you!

got it . than please explain me this whole i am little confused

Well, which tests is your code failing? That will help us understand what’s going on.

It doesn’t look like you are using item at all, by the way. That probably needs to be put into the arr somehow. That will fix one of the issues.

Also note, shift() doesn’t take any arguments. shift() returns the removed value.

yes thanks–but can u please tell me the solution for this as i am still on the same problem

Still no. We don’t give out solutions on the forum.

But if you tried to make some changes, I’d be happy to look at them. Or if you have some questions I’d be happy to answer them.

1 Like

okay then please tell me how to do this … i am not getting what’s being asked
thanks

I’m still not going to give you the answer.

What part/parts aren’t you getting? I am here to answer questions that don’t involve me doing it for you.

Do you understand what you are supposed to do with item? You aren’t currently using it correctly.

and second problem is that how actually are we using (item)

But that’s not what you are supposed to do with item

Write a function nextInLine which takes an array ( arr ) and a number ( item ) as arguments.

Add the number to the end of the array, then remove the first element of the array.

You need to add the item to the end of the array.

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function nextInLine(arr, item) {
// Only change code below this line
arr.push(6);
arr.shift(1);
arr.shift(2);
return item;
// 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));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55

Challenge: Stand in Line

Link to the challenge:

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function nextInLine(arr, item) {
// Only change code below this line
arr.push(6);

return item;
// 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));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55

Challenge: Stand in Line

Link to the challenge:

Hello @gautamjiyadav077

Requirement:
You will have to add the given item(2nd argument) to the end of an array(1st argument)
Finally, Delete the first item from that array and return the deleted item.

Now comment on your code

  1. The shift method does not need an argument.
  2. No need to call shift method twice.
  3. You are actually returning the provided item (2nd argument), make sure to return the deleted item.
1 Like

I have merged your two topics. Please do not create multiple topics for the same question. Instead, if you have updated code or information please include them in your original thread so that we can best help you.

It also looks like in both cases you chose not to answer the “Tell us what’s happening” prompt. We cannot answer questions that you don’t ask and we cannot help if we don’t know what’s going on.