0
Creating a chance miss system. Any help for a newbie?
Hi guys, Iâm new to coding and am trying to do something but canât seem to figure out how. The basic code: Var z=pickRandom(2) For(var I=100,I>0,i-20) if(z<2) print I Else Print(âmissâ) if(I===0) print (âdoneâ) what I want to have happen is if z=1 it prints I and if it doesnât it does not subtract 20 from I. After it loops once I want it to repick z and loop again. The outcome should look something like: 100 Miss Miss 80 60 40 Miss 20 Miss Miss Done I know this is not the easiest but any help would be appreciated.
2 RĂ©ponses
+ 2
JME Math.ceil
+ 1
Math.floor(Math.random() * 2) + 1; is how to generate a random number between 1&2, this needs to go in the loop so a new number is picked every iteration.
If you need more help please reply with a link to your attempt in a code playground