It appears my code delivers what the lesson requires, yet it indicates an error.
See original GitHub issueChallenge 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:
- Created 7 years ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
.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:
@knappsacks You’ve set
arr
toarr.push(item)
, which returns an integer representing the new length of the array.arr
now has the value of6
, and thereforearr.shift
is not a function. The key idea is thatarr.push(item)
modifies the array itself, and doesn’t need the assignment.