function nextInLine(arr, item) {
// Your code here
return item; // Change this line
}
// Test Setup
var testArr = [1, 2, 3, 4, 5];
how do i write the code for nextInLine([], 1) which would return 1
function nextInLine(arr, item) {
// Your code here
return item; // Change this line
}
// Test Setup
var testArr = [1, 2, 3, 4, 5];
how do i write the code for nextInLine([], 1) which would return 1
function nextInLine(arr, item) {
// Your code here… below is how I did it
//push will add item variable at the end of the arr(array)
arr.push(item);
//shift will remove the first element of the array
return arr.shift(); // Change this line… I changed this line also
}
make sure to add relation to what you did to the lines of code below, there will be a variable (testArr) change that to (arr). I don’t know about your challenge how it’s displayed but that’s how mine is and that’s how i did. I hope you got the point.
thank you…finally it has worked.