Intermediate
Accept dogs without letting a function ruin them
describe reads a list of animals. Today it is declared with Animal[], which lets it push a Cat into a list that others see as Dog[].
Change the parameter type so a Dog[] and a readonly Dog[] are both accepted, but the function cannot push. Keep the printed result (animal).
What Check tests
- Your code has no type errors
- The program prints animal
- A readonly list is accepted
- The parameter can no longer be pushed to
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.