1.

Write the equivalent script for the following code using for loop without effecting the output:<SCRIPT LANGUAGE="Javascript">var count=new Array();i=0;do{if(i%2 == 0)count[i]=1;elsecount[i]= i *10;i=i+1;}while(i<=5)</SCRIPT>

Answer»

<SCRIPT LANGUAGE="Javascript">

var count=new Array()

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

{

if(i%2 == 0)

count[i]=1;

else

count[i]= i *10;

}

</SCRIPT>



Discussion

No Comment Found

Related InterviewSolutions