Determine the value

Report a typo

Given code that processes strings:

val str1 = "aaabbcccdaa"
var str2 = " "

for (ch in str1) {
    if (ch != str2.last()) {
        str2 += ch
    }
}

What is the value of str2?

The function str.last() returns the last element in the str string, similar to an array function last().

Select one option from the list
___

Create a free account to access the full topic