exam questions

Exam 70-480 All Questions

View all questions & answers for the 70-480 exam

Exam 70-480 topic 4 question 36 discussion

Actual exam question from Microsoft's 70-480
Question #: 36
Topic #: 4
[All 70-480 Questions]

You have a webpage that includes the following markup and code:

You need to troubleshoot the code by clicking the Submit button.
Which value will be displayed?

  • A. 10
  • B. 20
  • C. Undefined
  • D. Runtime error
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
* The outermost assignment, counter = 10; will decide the output that is displayed.
* Local variables have local scope: They can only be accessed within the function.

Example -
// code here can not use carName
function myFunction() {
var carName = "Volvo";
// code here can use carName
}
* A variable declared outside a function, becomes GLOBAL.
A global variable has global scope: All scripts and functions on a web page can access it.

Example -
var carName = " Volvo";
// code here can use carName
function myFunction() {
// code here can usecarName
}
Reference: JavaScript Scope

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
urielrodz
4 years, 5 months ago
The answer is incorrect because Var is in a global scope so the answer is B
upvoted 1 times
Leonard
4 years, 5 months ago
Fun is a function that was never called
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...