0 votes
in JavaScript by

Which one of the following is the possibly correct output for the given JavaScript code?

functionfun(int length)  

{  

    int a=5;  

    for(inti=0;i<length;i++)  

    {  

        console.log(a);  

    }  

}  

fun(2);  

a) 5

b) 555

c) 55

d) error

1 Answer

0 votes
by

Answer: C

Reason: In the "for" loop statement, first of all, the variable's initialization takes place and checks the condition of the given expression. After that, the statements written in the body of the "for" loop statement are executed. The value of the variable gets incremented after each iteration until the condition gets false.

Related questions

0 votes
asked Mar 23, 2021 in JavaScript by sharadyadav1986
+1 vote
asked Mar 21, 2021 in JavaScript by rajeshsharma
...