Programming in Kotlin - Part 30: Challenge: Arrays | Ray Wenderlich

Practice using arrays on your own, through a hands-on challenge.

This is a companion discussion topic for the original entry at


the array challenge Material course starter is different from the one on the video solution.

The only difference I can see is the final project has:

println(“Index of Dan = ${players.indexOf(“Dan”)}”)

Hi @kevindmoore. All the starter has is the below. It doesn’t have the starting arrays or the 3rd challenge.

fun main(args: Array<String>) {
 Use index(of:) to determine the position of the element "Dan" in players.
    // Your solution here

 Write a for-in loop that prints the players' names and scores.

    // Your solution here


The statement for the list of players is:
var players = arrayOf(“Alice”, “Bob”, “Dan”, “Eli”, “Frank”)

and for the for loop:
players = arrayOf(“Anna”, “Brian”, “Craig”, “Dan”, “Donna”, “Eli”, “Franklin”)
val scores = arrayOf(2, 2, 8, 6, 1, 2, 1)

Hi @kevindmoore.
Please try to download project files and test them yourself.
The project files are definitely different with the other lessons.
The project files for this lesson has no final project file and I’ve could not run main.kt.

@kevindmoore Can you please help with this when you get a chance? Thank you - much appreciated! :]

Project files will be updated shortly.

Another solution to the 2nd part of this challenge than the one offered up in the video:

for(player in players) {
	println("$player ${scores[players.indexOf(player)]}")	

Also, the challenge-arrays-starter Kotlin project does not include the forEachIndexed challenge found in challenge-arrays-finished.

The forEachIndexed example was an ‘alternative’ solution. The starter project only required one way of doing things but I provided 2 ways to show how it could be done.