Number.times in JavaScript (naive solution)