Stand in Line Tutorial

Stand in Line Tutorial
0

#1

Tell us what’s happening:
Please guys, I had to stop this tutorial all because of this challenge. Help me out, I’m lost.

Your code so far


function nextInLine(a, b) {
  // Your code here
  a = 12;
  b = 4;
  a + 1 = b;
  return b;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/stand-in-line/


#2

There are a number of issues with your code, but the biggest issue is that you don’t seem to understand what the assignment is. You need to add a value to an array and return a value that you remove from the array.


#3

please what can I do. TBH I don’t understand this chapter.


#4

If you can not remember how to add an element to the end of an array or how to remove an element from the beginning of an array, I suggest you review the following previous challenges:

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/manipulate-arrays-with-push

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/manipulate-arrays-with-shift


#5

Thanks to everyone that contributed. I got it. This was the code I used, tho’ I looked it up on the net: function nextInLine(arr, item) { // Your code here arr.push(item); const shifted = arr.shift(); return shifted; // Change this line }