Stand in Line javascript

Stand in Line javascript
0.0 0

#1

i dont understand this challenge kindly help me out

Your code so far


function nextInLine(arr, item) {
  // Your code here
  
  return item;  // 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 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

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


#2

A perfect example would be this scenario; you are in a store with long queues paying, the first person in line is the first to go and the new ones joins at the back. The test is asking you to create a function that takes 2 arguments or parameters, 1 is an array and 2nd is an item… You are given the testArr as an example or test setup that you will use in replacement to the array parameter.

Hint: find the array function here https://www.w3schools.com/jsref/jsref_obj_array.asp and use it so you can return the array with the result

You don’t need to edit the 1st and 3rd console.log below, just edit the function and run the program, try to experiment values on the 2nd console.log below, hope it helps.