Forum Discussion

VasanthVijay's avatar
VasanthVijay
Contributor
11 years ago

Reg:Array relate querry

sample example

var array = new array('0','1');

for(i = 0;i < array.length;i++)

{

    switch()

    {

        case 0:

             log.message('hi');

            break;

       case 1:

            log.message("hello");

           break;

        default :

         break;

     }

}





i want out put of

hi and hello but only showing hi

how to fix this one.



thanks in advances

vasanth.v

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Written as follows (in JScript) it works fine.



    function ArrayDefault()

    {var Testarray = new Array('0','1');


    for(i = 0;i < Testarray.length;i++)


    {


        switch(i)


        {


            case 0:


                 Log.Message('hi');


                break;


           case 1:


                Log.Message("hello");


               break;


            default :


             break;


         }


    }


    }



    Are you using JScript?  Notice that I had the "switch" statement using the index "i" and that I capitalized "Array" in the declaration statement.