Ask Question
20 December, 15:48

What is displayed in the alert dialog box after the following code is executed? var items = 3; for (var i = 1; i = 1; j--) { result * = j; } alert ("The factorial of " + i + " = " + result); }

+1
Answers (1)
  1. 20 December, 17:28
    0
    The factorial of 3=6

    Explanation:

    Following are the description of the given question

    This is jа vascript code. Here items are the variable that are holding the integer value "3". After that there is 2 loop are iterating one is outer and one inner loop. When i=1 1=1 condition of inner loop is true it executed the statement inside the inner loop so result = 1. Now we increment the value of i of the outer loop. i=2 2=1 condition of inner loop is true it executed the statement inside the inner loop so result = 2. Now we increment the value of i of the outer loop. Now i=3 3=1 condition of inner loop is true it executed the statement inside the inner loop so result = 6. Now we increment the value of i of the outer loop. i=4 4<=3 the condition of outer loop is false the control moves from the outer loop. It print The factorial of 3=6
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What is displayed in the alert dialog box after the following code is executed? var items = 3; for (var i = 1; i = 1; j--) { result * = j; ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers