Stand in Line: How to complete this challenge?

Below is my first step

nextInLine([2], 1) should return 2

It’s telling me what it “should” be, but how am I supposed to know what to actually start writing? Like how do you take a problem and automatically “know” what to start writing to solve the problem? Like do I start with a function or a variable or a loop or an if/else or how do you know what to start writing?

For example, the first step (above) says nextInLine([2], 1) but I don’t even see where it says that or is displayed like that in the actual problem at all. This makes no sense literally at all.