Tell us what’s happening:
Hi, I understood the solution but I don’t quite get how it satisfies some of the challenge instructions:
List itemnextInLine([], 5)should return a number. // Is this instruction trying to state something different from the next one?
List itemnextInLine([], 1)should return 1. // Is it because after pushing 1, it becomes the first element in arr (since it is empty in this example (is it?))?
List itemAfter nextInLine(testArr, 10), testArr[4]should be 10. // No idea.
Can somebody explain, please? Thank you!
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36.
List itemnextInLine([], 5) this means the line is empty, so the number five will enter the line and be served next. Thereofre, the function returns 5.
List itemnextInLine([], 1) same as before. An empty line, whoever get in line next (1) will be removed next.
List itemAfter nextInLine(testArr, 10) I don’t know what this array testArr holds. It probably has a lot of elements and the test is just checking if you are not removing something you’re not supposed to. Maybe it testArr = [0, 1, 2, 3, 4, 5, so after the function runs, testArr should turn to [1, 2, 3, 4, 10] and the providede argument was successfully added to the end of the line.