question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

It appears my code delivers what the lesson requires, yet it indicates an error.

See original GitHub issue

Challenge Stand in Line has an issue. User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function nextInLine(arr, item) {
  arr.push(item);
  return arr.splice(0, 1);
}

// Test Setup
var testArr = [];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1));
console.log("After: " + JSON.stringify(testArr));

It appears my code delivers what the lesson requires, yet it indicates an error.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
raisedadeadcommented, Jul 25, 2016

.splice will return an array, while the tests are looking for a number. Hence with although your code prints the correct output it fails the test.

I feel we should add a testcase stating:

nextInLine should return a number.

0reactions
ja5087commented, Oct 21, 2016

@knappsacks You’ve set arr to arr.push(item), which returns an integer representing the new length of the array. arr now has the value of 6, and therefore arr.shift is not a function. The key idea is that arr.push(item) modifies the array itself, and doesn’t need the assignment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Khan Academy Algorithms List Flashcards - Quizlet
Study with Quizlet and memorize flashcards containing terms like A statistician developed this procedure to calculate the "variance" of a list of numbers....
Read more >
What is the Difference between Error, Defect, and Failure?
The Error is a human mistake. An Error appears not only due to the logical mistake in the code made by the developer....
Read more >
Computer Programming
Pseudocode is an English-like nonstandard language that lets you state your solution with more precision than you can in plain English but with...
Read more >
Error Reporting and Disclosure - Patient Safety and Quality
Over half indicated that patients should learn details of errors on request by patients or ... But silence kills, and health care professionals...
Read more >
Strategies for Learning from Failure - Harvard Business Review
And successful learning from failure is not simple: It requires ... that all failure is bad (although it usually provides lessons) and that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found