Issue understanding Data structure

Tell us what’s happening:
Describe your issue in detail here.
Can someone help explain this exercise so that i can understand it and how it works

  **Your code so far**

function nextInLine(arr, item) {
// Only change code below this line

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 (Linux; Android 12; SM-G980F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.79 Mobile Safari/537.36

Challenge: Stand in Line

Link to the challenge:

What specifically do you need clarification on?

The challenge is asking you to add the item to the end of the array. Then remove the first element from the array and return it out of the function.

I’d suggest you go back to the sections that all start with “Manipulate Arrays With” they have the methods you need for this challenge.

Help me out with an example

We are not going to write the answer for you. That does not help.

HI @andrenz !

Maybe it would help to break the example down into smaller chunks.
Learning how to break a problem down is important in programming something you will do all the time on the job.

Here are the first part of the directions:
Add the number to the end of the array,

Do you know how to add something to the end of an array?
If not, I would suggest googling “add number to end of array javascript” and the method you need to use will be the first result.
Give it try and reply back to us with your code

After nextInLine(testArr, 10), testArr[4] should be 10

I don’t understand that line above

As the task is to add an element to and remove an element from the array, it expects that value as last element of the array after the function runs

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