nerdexam
Microsoft

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 =…

Perform Operations using Data Types and Operators

Question

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 value of each variable at line 07? To answer, drag the appropriate value to the correct variable. Each value may be used once, more than once, or not at all.

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

#variable assignment#arithmetic operators#modulo#expression tracing

Community Discussion

No community discussion yet for this question.

Full 98-382 Practice