Challenge: displayMenu() Function

Here is a coding challenge based on the use of functions.

We'll cover the following

Problem statement #

Define a printMenu() function to take the entire set of menu items as a parameter. For example, the menu items can be passed to the function as in the following code:

string[] items = [ "Black", "Red", "Green", "Blue", "White" ];
printMenu(items, 1);

Output #

Have the program produce the following output:

1 Black
2 Red
3 Green
4 Blue
5 White

Challenge #

This problem is designed for you to practice, so try to solve it on your own first. If you get stuck, you can always refer to the explanation and solution provided in the next lesson. Good luck!

Get hands-on with 1200+ tech skills courses.