Freecodecamp: Stand In Line challenge: Here's my code: But system won't allow me to proceed I don't know why?

Created on 6 Oct 2016  路  5Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge Stand in Line has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function nextInLine(arr, item) {
  // Your code here

  testArr.push(item);
  return testArr.shift();  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 5)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Most helpful comment

@ahmedghandour thanks for the issue but if you get stuck or have questions with a challenge in the future, please first ask questions to the Help Room. Hint: please review your knowledge of function scope. You can only use variables that are scoped by your function. Happy coding!

All 5 comments

Challenge works fine and here is an example of that. Problem is in your code, so check it again and tell me how it goes ;)

screenshot at 2016-10-06 11 41 02

By the way, you need to change the code and not leave it like you got it. It won't let you pass...

@ahmedghandour you have a small error in your code. In the future, please post in the HelpJavascript Gitter channel first. If the consensus there is that it is a bug, then you should post here.

@ahmedghandour thanks for the issue but if you get stuck or have questions with a challenge in the future, please first ask questions to the Help Room. Hint: please review your knowledge of function scope. You can only use variables that are scoped by your function. Happy coding!

Thanks guys, I'll try again and again until it is Ok, and I'll post in the help it was my mistake

Thanks a lot erictleung, you've been of great help. Thanks again.
I passed the challenge.

Was this page helpful?
0 / 5 - 0 ratings