function nextInLine(arr, item) { // Only change code below this line arr.push(item); return arr.shift(item); // Only change code above this line } // Setup var testArr = [1,2,3,4,5]; // Display code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine(testArr, 6)); console.log("After: " + JSON.stringify(testArr));
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter