Skip to content

Instantly share code, notes, and snippets.

@DougCal
Created June 14, 2016 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DougCal/3c50a7f2ec2a7b05b13496a263a4ef33 to your computer and use it in GitHub Desktop.
Save DougCal/3c50a7f2ec2a7b05b13496a263a4ef33 to your computer and use it in GitHub Desktop.
Stand in Line Challenge freecodecamp.com
function nextInLine(arr, item) {
// Your code here
var first = arr[0];
arr.push(item);
arr.shift();
return first; // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment