Does anyone know this solution. Have been trying to solve it for a long time. Your discussion on it will be extremely helpful πŸ€— | Sololearn: Learn to code for FREE!

+1

Does anyone know this solution. Have been trying to solve it for a long time. Your discussion on it will be extremely helpful πŸ€—

Filtering Names You are given an array of names and need to output only the names that start with the given letter. The letter should be taken from user input. Each of the resulting names should be output on a separate line. fun main(args: Array<String>) { var letter = readLine()!![0] val names = arrayOf("John", "David", "Amy", "James", "Amanda", "Dave", "Bob", "Billy", "Bobby", "Diana", "Lenny", "Gina") }

4/9/2021 5:37:29 AM

Fardina Kabir

1 Answer

New Answer

+2

Q: How to iterate over an array? A: array.forEach() {do something with each} Q: What's Kotlin name for each of the items? A: it Q: How to get first letter of item? A: it[0] Q: How to print line by line? A: println(it[0]) And befor print, you have to compare it[0] with the input. We saw a comparisation like this yesterday πŸ˜‰