Tell us what’s happening:
I put in code that yielded the exact same results as both the video and the requirements from what I saw. I’m in no saying it was the best way to do it, but it got the same results. So now I want to know what was different and why I didn’t get the right answer? I did it two different ways both yielded the same results, but they were both ruled wrong.
Your code so far
function nextInLine(arr, item) {
// Only change code below this line
// testArr.push(item);
// arr = testArr.shift();
// console.log(arr);
-------------------------------------------------------------------------------------
//return arr;
// arr.push(item);
// return arr.shift(item);
testArr.push(item);
item = testArr.shift();
// console.log(item);
return item;
// Only change code above this line
}
// Setup
var testArr = [1,2,3,4,5];
// Display code
console.log(testArr);
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; rv:76.0) Gecko/20100101 Firefox/76.0
.
Challenge: Stand in Line
Link to the challenge: