So I have elements that are position: absolute and then I use Math.random() to set their left:#random and top:#random position.
However a very weird thing is happening. It should be completely random, thus they should be placed completely randomly. However time and time again, they are placed very closely together. Instead of being spread apart.
however you can clearly see, their positions are indeed random:
Here is the code I use to generate them:
const Clouds = function(props) {
const clouds = []
for (let i = 0; i < props.cloudNum; i++) {
const style = {
position: 'absolute',
height: 50 * props.cloudSize + 'px',
top: Math.random() * 100 + '%',
left: Math.random() * 100 + '%',
}
clouds.push(<Cloud key={i} style={style} />)
}
return <div className={props.side}>{clouds}</div>
}
is there a temporal component to Math.random, and because they are generated in sequence their random numbers are similar?