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;}
//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
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
...
This section is not available anymore. Please use the main Exam Page.70-480 Exam Questions
Log in to ExamTopics
Sign in:
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.
BadBot
Highly Voted 5 years, 1 month agoKebo
Most Recent 4 years, 11 months agoSanfour
5 years ago