exam questions

Exam 70-480 All Questions

View all questions & answers for the 70-480 exam

Exam 70-480 topic 4 question 91 discussion

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

You are creating a custom object as described by the following code. Line numbers are included for reference only.

You need to implement the perimeter method.
Which code segment should you insert at line 05?

  • A. function perimeter () {return 4 * side;}
  • B. function perimeter () {return 4 * this.side;}
  • C. function perimeter () {return 4 * me.side;}
  • D. function perimeter (obj) {return 4 * obj.side;}
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
http://creative-coding.decontextualize.com/objects-with-methods/

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
BadBot
Highly Voted 5 years, 1 month ago
Poorly formed question. "At line 5" means that you are outside the scope of the square-object. B is correct "inside" the object, D is correct outside.
upvoted 7 times
...
Kebo
Most Recent 4 years, 11 months ago
//correct answer B function square(side) { this.side = side; //reference to the perimeter function defined below this.perimeter = perimeter; } function perimeter() { return 4 * this.side } /// const firstSquare = new square(4); //here we call the perimeter as a method of firstSquare this refers to the firstSquareObject firstSquare.perimeter(); //test this code to the console of any browse it works
upvoted 2 times
...
Sanfour
5 years ago
no that mean that you have a copy of function perimeter inside the square function function square(side){ this.side=side; this.perimeter = perimeter; console.log(perimeter());} undefined square(4); the result is 16
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 ...