+2 votes
in Class 12 by kratos

Write the equivalent script for the following code using for loop without effecting the output:

var count=new Array();

i=0;

do

{

if(i%2 == 0)

count[i]=1;

else

count[i]= i *10;

i=i+1;

}while(i<=5)

1 Answer

+1 vote
by kratos
 
Best answer

var count=new Array()

for(i=0;i<=5;i++)

{

if(i%2 == 0)

count[i]=1;

else

count[i]= i *10;

}

...