98-382 · Question #4
Evaluate the following code. Line numbers are included for reference only. 01 var n = 50; 02 var c = n + 5; 03 var a = n % 2; 04 var d = c / 11; 05 n = d * 2; 06 console.log(n, c, a, d); What is the…
Let's trace the execution of the code line by line: 01 var n = 50; // n is initialized to 50 02 var c = n + 5; // c = 50 + 5 = 55 03 var a = n % 2; // a = 50 % 2 = 0 (remainder of 50 divided by 2) 04 var d = c / 11; // d = 55 / 11 = 5 05 n = d 2; // n is reassigned: n = 5 2 =…
Question
Explanation
Let's trace the execution of the code line by line:
01 var n = 50; // n is initialized to 50 02 var c = n + 5; // c = 50 + 5 = 55 03 var a = n % 2; // a = 50 % 2 = 0 (remainder of 50 divided by 2) 04 var d = c / 11; // d = 55 / 11 = 5 05 n = d * 2; // n is reassigned: n = 5 * 2 = 10 06 console.log(n, c, a, d); // At this point, n=10, c=55, a=0, d=5
At line 07 (after the execution of line 06), the values of the variables are:
- n: 10
- c: 55
- a: 0
- d: 5
Topics
Community Discussion
No community discussion yet for this question.