Hello everybody I am new free code camper and I have a problem with this subject. I have been working on the problem for a few days now and I think I understand the problem, but after I tested the program I got no pass to the next subject.
Here is the code:
function nextInLine(arr, item) {
// Your code here
testArr.push(item);
var removedItem = testArr.shift();
return removedItem; // Change this line
}
// Test Setup
var testArr = [5,6,7,8,9];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Please, I need to know what am I doing wrong is there something I am missing?
Thank you in advance.
You are using a global testArr variable. Why? You need to use the parameter they give you (in this case the arr parameter).
function nextInLine(arr, item) {
// Your code here
arr.push(item);
var removedItem = arr.shift();
return removedItem; // Change this line
}
// Test Setup
var testArr = [5,6,7,8,9];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Thank you IsaacAbrahamson! That part I didn’t think of it. I was focusing in the Display area code more than the actual function, probably burned from not stepping back. Anyway, thank you very much for the fast responding.