Freecodecamp: Correct Answer not Recognized

Created on 9 Apr 2016  Â·  11Comments  Â·  Source: freeCodeCamp/freeCodeCamp

screen shot 2016-04-09 at 4 46 02 pm
Challenge Stand in Line has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36.

It appears that the array is modified correctly and the correct value is returned, yet the third success requirement is not satisfied.

My code:

function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  var removed = testArr.shift(arr);
  return removed;
    // 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));

Most helpful comment

Solved it. Dont use testArr use arr

Sent from my iPhone

On 16 Mab 2016, at 9:33 AM, amolinasf [email protected] wrote:

I did manage to resolve it, I cant remember off the top of my head how i
did it exactly.

-AM

On Sat, Apr 16, 2016 at 8:18 AM, Nely [email protected] wrote:

Hi, did you resolve this? Im getting the same error.

function nextInLine(arr, item) {
var addNum= testArr.push(item);
var removeNum= testArr.shift();// Your code here

return removeNum; // 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));

―
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/8013#issuecomment-210745265

―
You are receiving this because you commented.
Reply to this email directly or view it on GitHub

All 11 comments

@amolinasf Hint: I would double check what arrays you are modifying in your function. In general, code issues are not handled on GitHub unless there is a bug with the site. Please take all coding questions to the Help Room. Happy coding!

Hi, did you resolve this? Im getting the same error.

function nextInLine(arr, item) {
var addNum= testArr.push(item);
var removeNum= testArr.shift();// Your code here

return removeNum; // 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));

I did manage to resolve it, I cant remember off the top of my head how i
did it exactly.

-AM

On Sat, Apr 16, 2016 at 8:18 AM, Nely [email protected] wrote:

Hi, did you resolve this? Im getting the same error.

function nextInLine(arr, item) {
var addNum= testArr.push(item);
var removeNum= testArr.shift();// Your code here

return removeNum; // 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));

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/8013#issuecomment-210745265

Solved it. Dont use testArr use arr

Sent from my iPhone

On 16 Mab 2016, at 9:33 AM, amolinasf [email protected] wrote:

I did manage to resolve it, I cant remember off the top of my head how i
did it exactly.

-AM

On Sat, Apr 16, 2016 at 8:18 AM, Nely [email protected] wrote:

Hi, did you resolve this? Im getting the same error.

function nextInLine(arr, item) {
var addNum= testArr.push(item);
var removeNum= testArr.shift();// Your code here

return removeNum; // 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));

―
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/8013#issuecomment-210745265

―
You are receiving this because you commented.
Reply to this email directly or view it on GitHub

Apparently you need to use arr instead of testArr

On 16 Mab 2016, at 9:33 AM, amolinasf [email protected] wrote:

I did manage to resolve it, I cant remember off the top of my head how i
did it exactly.

-AM

On Sat, Apr 16, 2016 at 8:18 AM, Nely [email protected] wrote:

Hi, did you resolve this? Im getting the same error.

function nextInLine(arr, item) {
var addNum= testArr.push(item);
var removeNum= testArr.shift();// Your code here

return removeNum; // 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));

―
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/8013#issuecomment-210745265

―
You are receiving this because you commented.
Reply to this email directly or view it on GitHub

Help! I have a similar problem. This is my code :

`function nextInLine(arr, item) {
// Your code here
arr.push(6);
return item = arr.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, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
`

Apparently you need to use arr instead of testArr

On Mon, Apr 18, 2016 at 5:54 PM, Alex [email protected] wrote:

Help! I have a similar problem. This is my code : `function
nextInLine(arr, item) {
// Your code here
arr.push(6);
return item = arr.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, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
`

—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/8013#issuecomment-211441814

function nextInLine(arr, item) {
// Your code here
arr.push(item);
return item = arr.shift();
// return item; // Change this line
}

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

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

Hi,
The below code work for all

function nextInLine(arr, item) {
// Your code here
arr.push(item);
return item = arr.shift();
// return item; // Change this line
}

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

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

Here is the answer for those who are still struggling

[
// Your code here
arr.push(item);
return arr.shift(); // Change this line
}

Was this page helpful?
0 / 5 - 0 ratings