Tell us what’s happening:
Your code so far
function nextInLine(arr, item) {
// Only change code below this line
nextInLine([], 5);
return item;
nextInLine([], 1);
return item;
nextInLine([2], 1)
return[0];
nextInLine([5, 6, 7, 8, 9], 1)
return[0][0];
// Only change code above this line
}
// Setup
var testArr = [1,2,3,4,5];
// Display code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
.
Challenge: Stand in Line
Link to the challenge:
ILM
2
do not call the function inside itself like that, everything crashes if you do that
try to understand what are the function requirements
@ILM can you re-write the code yourself
ILM
4
no, I will not give you the solution
try understanding what’s the corresponding output for each input
I’m been stucked there I’ve tried doing that yet the code isn’t working.
I will appreciate you rewrite the code.
ILM
6
I will not give you the solution
what have you tried other than calling the function inside itself?
1 Like
jsdisco
7
Do you know the .push
and .shift
methods?