Array.from()
takes an iterable object to convert to an array and an optional map function. You could create an object with a .length
property as follows:
return Array.from({length: this.props.level}, (item, index) =>
<span className="indent" key={index}></span>
);