Monkuar Posted September 18, 2012 Share Posted September 18, 2012 im completely stuck.. All I need to do is add another d(v4)... for (var i = 0; i < c; i++) { v3 = v2 = v1 = rnd(0, 9); while (v2 == v1) v2 = rnd(0, 9); while (v3 == v1 || v3 == v2) v3 = rnd(0, 9); d(v1); d(v2); d(v3); } I added the d(v4) to the variables here: for (var i = 0; i < c; i++) { v4 = v3 = v2 = v1 = rnd(0, 9); while (v2 == v1) v2 = rnd(0, 9); while (v3 == v1 || v3 == v2) v3 = rnd(0, 9); d(v1); d(v2); d(v3); d(v4); } But I need to add something to the while loops, not sure I am so stuck >_< I just need to beable to use that other v4 so it's random and the rnd returns a function: function rnd(l_, h_) { return Math.round((Math.random() * (h_ - l_)) + l_); } Thanks Anyone with JS knowledge tell me what actually am I doing wrong/etc? Looking and seeking some nice help hehe, I Want to tackle this bug/problem I Cannot fathom this anymore, lol Quote Link to comment https://forums.phpfreaks.com/topic/268504-help-finish-this-loop/ Share on other sites More sharing options...
Adam Posted September 18, 2012 Share Posted September 18, 2012 What exactly are you trying to do? You've just provided a load of random code and said 'I need to another d(v4)' .. Quote Link to comment https://forums.phpfreaks.com/topic/268504-help-finish-this-loop/#findComment-1378856 Share on other sites More sharing options...
Monkuar Posted September 18, 2012 Author Share Posted September 18, 2012 What exactly are you trying to do? You've just provided a load of random code and said 'I need to another d(v4)' .. nevermind... sorry as u can tell i clearly no idea how to work with this ij ust fixed it by doing this for (var i = 0; i < c; i++) { d(rnd(0,9)); d(rnd(0,9)); d(rnd(0,9)); d(rnd(0,9)); } if anyone has this same problem their is the fix, while loops are bugged like a mofo in js, man i hate js lol Quote Link to comment https://forums.phpfreaks.com/topic/268504-help-finish-this-loop/#findComment-1378865 Share on other sites More sharing options...
Adam Posted September 18, 2012 Share Posted September 18, 2012 Glad it's sorted. I don't think you can blame it on the while loop being 'bugged' though. They work exactly as they do in PHP, or any other language. Quote Link to comment https://forums.phpfreaks.com/topic/268504-help-finish-this-loop/#findComment-1378868 Share on other sites More sharing options...
Monkuar Posted September 18, 2012 Author Share Posted September 18, 2012 Glad it's sorted. I don't think you can blame it on the while loop being 'bugged' though. They work exactly as they do in PHP, or any other language. your right, i apologize. i just hate working with php and then switching back to javascript, javascript is kinda identical but some shit just confuses the hell out of me, :-\ and ya the only thing bugged was prob my brain the arrays in javascript is what really piss me off, not even close to what im familiar with arrays with php (IMO) Quote Link to comment https://forums.phpfreaks.com/topic/268504-help-finish-this-loop/#findComment-1378869 Share on other sites More sharing options...
Adam Posted September 18, 2012 Share Posted September 18, 2012 Well technically when it comes to arrays, PHP is actually the black sheep amongst languages. JS is pretty standard, in that you can only have sequential, integer indexed arrays. If you want the equivalent of an 'associative' PHP array, just use a standard object. Quote Link to comment https://forums.phpfreaks.com/topic/268504-help-finish-this-loop/#findComment-1378876 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.