0
var jaar = 2014 ; 
var dagen = new Array("maandag ", "dinsdag ", "woensdag ", "donderdag ", "vrijdag ", "zaterdag ", "zondag ");
var dag = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]


document.write("<h2>januari</h2> <br> <br>");
for(i = 0 ; i < dagen.length ; i++)
{

    document.write(dagen[i]);

     if( i == 2)
    {
        for(x = 0 ; x < dag.length ; x++)
        document.write(dag[x])
    }
    else()
    {
    }    

}

For some reason my script isnt working, what i wanna do is that my second loop runs when my first loop is at his 2 array point. and i also want that my second loops runs one time. can someone help me ?

1
  • Just delete the else part and try again, in case of error, quote the error in your question. Commented Sep 25, 2014 at 10:06

2 Answers 2

1

else () will cause the syntax error. If you would like to check some condition in else condition, then use

else if(some condition){ }

or simply use

else {

}
Sign up to request clarification or add additional context in comments.

Comments

0

I have corrected your code. Please run the code given below.

var jaar = 2014 ; 
var dagen = new Array("maandag ", "dinsdag ", "woensdag ", "donderdag ", "vrijdag ", "zaterdag ", "zondag ");
var dag = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]


document.write("<h2>januari</h2> <br> <br>");
for(i = 0 ; i < dagen.length ; i++)
{

    document.write(dagen[i]);

     if( i == 2)
    {
        for(x = 0 ; x < dag.length ; x++)
        document.write(dag[x])
    }
    else
    {
    }    

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.