1,477 views
18 votes
18 votes
What is the value of the variable myAge when this program has run?

01 var my Age 16;
02 console.log("In fifty years, I will be");
03 console.log(myAge + 50);
04 myAge = myAge + 50;
05 console.log(myAge);
1. 50
2. 66
3. "66"
4. "myAge + 50"

User Tyler Zika
by
2.5k points

1 Answer

24 votes
24 votes

Answer:

2: 66

Step-by-step explanation:

You're defining a variable as myAge starting at 16.

var myAge = 16;

You simply print the variable by adding 50, but you're not assigning that + 50 to the variable, so it remains unchanged.

console.log("In fifty years, I will be");

console.log(myAge + 50);

- > myAge = 16;

Then you add myAge 50, so now the variable is 16 + 50:

myAge += 50;

So the variable myAge is now 66. Since it is an integer, it won't include quotes (it's not a String).

User Han Parlak
by
2.9k points