+ 6

Why doesn't the colors change?

I just started practicing canvas using JavaScript. I have a code which creates 10 circles in the page. The circle's location is already randomized but I want the stroke colors randomized as well. Still noobie in JS 🤦‍♀. Advance thanks for someone who can helps! 😅 https://code.sololearn.com/WUtC11ZZm1EW/?ref=app

29th Jun 2019, 6:43 AM
Nootnoot
Nootnoot - avatar
2 Antworten
+ 4
put var colorIndex = Math.floor (Math.random() * colorSheet.length) since you didnt..Math.random is creating decimal numbers which dont work in arrays..so Math.floor rounds it down to a whole number
29th Jun 2019, 7:22 AM
Jason Kennedy
+ 2
Oh it works! thanks alot Jason Kennedy! You really made my day! 😂
29th Jun 2019, 7:44 AM
Nootnoot
Nootnoot - avatar