Doubling each number in an array

Report a typo

You are given an array of integers. Your task is to double each number in the array. Fill the blanks in given Kotlin code to solve this task. The array is represented as MutableList in Kotlin. Keep in mind that in Kotlin, you could use 'for' loop and index to access and modify elements in MutableList.

Fill in the gaps with the relevant elements
fun main() {
    val numbers = (1, 2, 3, 4, 5)
     (i  numbers.) {
        numbers[i] = numbers[i] * 2
    }
    print(numbers.joinToString(", "))
}
mutableListOfinindicesfor

Create a free account to access the full topic