+ 9

Plz help

When I run this code it comes with an error. https://www.sololearn.com/post/174757/?ref=app

13th Nov 2019, 7:34 AM
Shreyansh
Shreyansh - avatar
7 odpowiedzi
+ 14
Try using : document.getElementById("img"); [Assuming you have an image with an id value img].
13th Nov 2019, 7:43 AM
Nova
Nova - avatar
+ 13
Tru using this : var x=Math.floor(Math.random()*i); Math.random() is used only to get random values between 0 and 1 like 0.4562737 or 0.818717 which when multiplied by any value of i will be 0. So you can floor down the result which gives you the exact number.
13th Nov 2019, 8:20 AM
Nova
Nova - avatar
+ 12
My pleasure 😊👍
13th Nov 2019, 8:26 AM
Nova
Nova - avatar
+ 6
Nova thanks it worked I was using square brackets
13th Nov 2019, 7:49 AM
Shreyansh
Shreyansh - avatar
+ 6
Nova plz help This code works fine when I output any specific image but I want to generate random images
13th Nov 2019, 8:09 AM
Shreyansh
Shreyansh - avatar
+ 5
Nova thanks bro I had been trying this for last few days
13th Nov 2019, 8:24 AM
Shreyansh
Shreyansh - avatar
+ 4
Nova I've tried Here is the link of code https://code.sololearn.com/Wn0mu628JD1d/?ref=app
13th Nov 2019, 7:46 AM
Shreyansh
Shreyansh - avatar