Whats wrong on my code? in Stand in Line

Whats wrong on my code? in Stand in Line
0.0 0

#1

function nextInLine(arr, item) {
// Your code here
arr = testArr;
arr.push(item);
return arr.shift(); // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr[2],1)); // Modify this line to test
console.log(nextInLine([5,6,7,8,9], 1));
console.log("After: " + JSON.stringify(testArr));


#2

The offending line is

arr = testArr;

#3

… and this one:

console.log(nextInLine(testArr[2],1)); // Modify this line to test

#4

isn’t working i tested


#5

Ignore testArr, use only the function arguments.


#6

Thanks everyone Problem Solved :relaxed:


#7

Stand in line

I am still having problems with this one.

function nextInLine(arr, item) {
// Your code here
arr = testArr;
arr.push(item);
return arr.shift(); // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr[2],1)); // Modify this line to test
console.log(nextInLine([5,6,7,8,9], 1));
console.log("After: " + JSON.stringify(testArr));

Can you help?


#8

return arr.shift(); // Change this line

this line has nothing you show. nowhere to store the value that was removed. trying saving the shifted number. then returning it

edit: didn’t realize this was 2 months old. so i will write the answer as i just figure this out.

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var anythng = arr.shift();
  return anything;  // Change this line
}