+ 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
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
+ 2
Oh it works! thanks alot Jason Kennedy! You really made my day! 😂