Complete the code to print a test message.
fun main() {
println([1])
}The println function prints the string inside quotes. We need quotes around the message.
Complete the code to check if a test result is true.
fun isTestSuccessful(result: Boolean): Boolean {
return result [1] true
}Use == to compare values in Kotlin. A single = is for assignment.
Fix the error in the test function to return the correct message.
fun testMessage(passed: Boolean): String {
return if (passed) [1] else "Test failed"
}The function must return a string. So the true branch needs a string literal with quotes.
Fill both blanks to create a list of test results and check if all passed.
val results = listOf([1], [2], false) val allPassed = results.all { it } println(allPassed)
true and false values.The list should contain Boolean values. Using true twice and false once creates a mixed result.
Fill all three blanks to create a map of test names to results and filter passed tests.
val testResults = mapOf([1] to [2], "test2" to false, "test3" to true) val passedTests = testResults.filter { it.value [3] true } println(passedTests.keys)
The map needs a string key and a Boolean value. The filter checks if the value equals true.
