Mar 22 in JavaScript
Q:

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
Mar 22

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.

Click here to read more about JavaScript
Click here to read more about Insurance
...