Issue with The Menu App Course, Challenge 5

I am currently doing the Menu App course. however, i am currently stuck on the Challenge on building a UI with a List and a Button below it. maybe im missing something, but the challenge is asking me to do things i dont believe we’ve covered yet? like getting the button to randomly generate a given output. is this reffering to the Card Game course?

Not too sure on how to do it, or to convert what we learnt in the Card Game course to this challenge.

Any help, Thanks!

Hi @JadeCantCode

Welcome to the community.

Yes, have a look at what you did when the Deal button was tapped. In the challenge the array you choose a random word from contains 5 strings so you can use the array method .count to return the number of entries in the array. Remember that the index pointer to the position of the elements in an array starts from 0 (being the first element) and given that the .count method returns the number of elements (you would expect 5) then the last index pointer value will be 4 which is one less. So you can say arrayName.count.

I hope I have given you enough hints for you to figure that out.

Search online for “Swift count the number of elements in an array” and “Swift select a random element from an array”.

1 Like