mardi 12 janvier 2021

Fill array with random picture from url that gives random picutres

The randomizer for width and height works, but it only gets first random photo from collection and generates 10 same images of various dimensions.

export const photos = Array.from({length:10},()=> 
    (
        {
            'src': 'https://source.unsplash.com/random',
            'width': Math.floor(Math.random() * 4) + 2,
            'height': Math.floor(Math.random() * 4) + 2
        }
    )
) 

What I would want is that it fills the array with 10 different pictures using that same link.




Aucun commentaire:

Enregistrer un commentaire