Skip to content
Advertisement

How to display a list of element in as a list in HTML from a Javascript array from an API?

My JS code is this but I want to be able to get the moves array to be displayed in HTML in a list format, how can I go about doing so?

JavaScript

Advertisement

Answer

You can use a safe helper to populate a node in the page, let’s say <div id="list"></div>, so that your code can do something like:

JavaScript

That will also do the right thing next time you call getData in case data changes.

Advertisement