First and last booking

Find the first and last items in an array of any nonzero length.

your task

Keep the count line. Fix the two guest lines. In a one-row table, both must show the same guest.

In the three-row case, the count is correct. The “first” line shows Jonas, and the “last” line shows undefined. The names in guests follow table order.

Starter code
or press Ctrl EnterNot run yet

cases

Not run yetThree rows

Expected output

1count: 3
2first: Mira
3last: Tove
See the input and the code for this case
const guests = ["Mira", "Jonas", "Tove"];
Not run yetOne row

Expected output

1count: 1
2first: Anouk
3last: Anouk
See the input and the code for this case
const guests = ["Anouk"];