This is the challenge for the Lessons 25 and 26 covering arrays and for loops. The purpose of ChallengeForXmenBattleCount is to take two existing arrays, one with names and the other with numbers that represents battles, loop through them and retrieve information to display to the user.


In your CS-ASP_026-Challenge folder, you’ll find a project that has already been started. Use this project for this challenge. In it, there are two arrays; names[] and numbers[]:


Each item in the two arrays correspond to the other. For instance, Iceman (located at index 1) would correspond to 9 (located at index 1 of the other array):


The challenge is to use a for loop to iterate through the arrays, locate the X-Man with the most battles and the X-Man with the fewest, then display the result to the user:


Note: The result will always be Phoenix with 17 and Wolverine with 2.

Don’t hard-code the resultLabel, you need to use arrays and loops to iterate through and find these values to display. Here’s a hint, though: You only need one for loop in order to complete this.

This challenge requires a lot of thinking, so take your time and consider the different ways of completing this. If you get stuck, read the solution document available to you. If you put together all we’ve learned about loops and arrays, I’m confident you can do this. Good luck!

Lessons in this Course