Answer the question
In order to leave comments, you need to log in
How to output n number of elements in React?
I have some variable count. I need to put count elements into template html variable. For example, if count = 4, then template must be equal to = " ". How to implement it? <td></td><td></td><td></td><td></td>
Answer the question
In order to leave comments, you need to log in
let count = 4
let template = Array(count).fill('<td></td>').join('')
console.log(template)
// -> <td></td><td></td><td></td><td></td>
let template2 = '<td></td>'.repeat(count)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question