Incorrect function stub and JSDoc type in Train Driver exercise

Hi, I noticed two issues with the starter code in this exercise:

  1. Function signature mismatch:
    The problem statement says the function should accept “an arbitrary number of wagon IDs,” but the provided function getListOfWagons explicitly lists parameters (a, b, c, d, e, f, g, h, i, j, k, l, m, n).
    To correctly support a variable number of arguments, the function should use the rest operator:
export function getListOfWagons(...ids) { ... }
  1. Invalid JSDoc type:
    The provided JSDoc uses @param {...numbers} ids, but numbers is not a valid JSDoc type. It should be @param {...number} ids or @param {number[]} ids.

Together these make the exercise confusing — especially since earlier tasks don’t mention the need to modify starter code or the JSDoc. Fixing these would make the instructions and code consistent and less misleading for learners.

Thanks for maintaining this track!

1 Like

Not a JS maintainer, but the first part about the function signature seems appropriate. Changing the function signature to use a rest parameter is surely part of the exercise so students are exposed to adding one.

For the second part, Use JSDoc suggests @param {...number} so the proposed change makes sense to me at least.

1 Like

Right above task 1 it says:

To practice, use the rest or spread operator to solve each of the tasks below.

If we changed the stub to no arguments we’d get the same complaint that it’s “confusing” and if we change it to ...ids, you miss the opportunity to learn.

The provided JSDoc uses @param {...numbers} ids , but numbers is not a valid JSDoc type. It should be @param {...number} ids or @param {number[]} ids .

You are correct. We’ll take a PR to change it to {...number} ids which is correct.

1 Like

Hi, I have a PR that fixes the incorrect JSDoc type.

1 Like

Thank you. Merged!

1 Like

Hello! I just got started on this exercise and must confess I’m utterly confused how to get started. The input in the text does not match the input in the example code.

Ok, never mind. Got it. Apparently I was supposed to change the params of the examplefunction. Must say this was not clear to me. I vote for leaving this empty :-)

(Maybe its just me! Entirely possible)

Glad you figured it out.