Jump to content

Recommended Posts

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 :P

Link to comment
https://forums.phpfreaks.com/topic/268504-help-finish-this-loop/
Share on other sites

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

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)

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.