Interacting with the DOM

Now that Doubloons4Gold is running in the browser, your next task is to revisit the functions you stubbed out before and provide a better user experience – one that does not involve opening the developer tools. You will start by updating your InputOutput.kt implementations to render content on the page. Then you will address the currency formatting in formatAsCurrency.

In your output function, you need to update the page to show the line of text being displayed. To do this, you will be interacting with the DOM, a set of APIs that let you programmatically modify pages declared in HTML. To make this task easier, you will use the Kotlinx HTML library, which offers a Kotlin-friendly API for declaring HTML elements ...

Get Kotlin Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.