Skip to content
Advertisement

Print set element in javascript

I am trying to print the set element through innerHTML, but I am not getting the desired result. While I tried with document.write(),it is printing but I want to use only innerHTML.

Here is my source code:

JavaScript

Output: 4

Desire output: 0 1 2 3 4

Please suggest me how to use innerHTML to print the output.I have tried console log and document.write(), they are working.

Advertisement

Answer

You can store all the value in a variable and then set that to the the element. Please note you can use textContent or innerText when the htmlString is only text.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement