Is there any better way to write this Kotlin-javascript function?

Thank you, even better :)