How do I output text to a web page as many times as a number stored in a variable?

How do I output text to a web page as many times as a number stored in a variable?

How do you want to output , a div ,li, heading or p tag

1 Like

I think a p tag would work best

There are two parts to your question here:

  • How do I output text to a web page?

This involves DOM manipulation. It sounds like you would be happy adding a new <p> element to add the text.

Adding a new element to the DOM with vanilla JS

  • As many times as a number stored in a variable?

This would involve some sort of loop (probably a for loop)

JavaScript for loop