Loop through an array and print how many thimes it gets repeated in Kotlin?
I'm leaning Kotlin, and I'm wondering if there is a better, simpler and not that complicated way to do this in kotlin? I need to Write a Kotlin program that loops through an array and generates a histogram based on the numbers in it.The results should look like this(vertically):
1: *****
2: **
3: **
4:
5: *
And this is what I did:
fun main() {
val myArray: IntArray = intArrayOf(1,2,1,3,3,1,2,1,5,1)
for(num in 1..5){
println("")
print("$num: ")
for(element in myArray) {...