Which three actions should you perform in sequence to complete the implementation?

DRAG DROP
You have the following code:

The web service returns a JSON object that contains two properties named Description and FileName.
The PersonImage object must meet the following requirements:
Create an object that represents an image that will be displayed.
Set the image properties from the values that are returned by the web service.
Expose the image as a property of the PersonImage object.
You need to insert code at line 13 to complete the implementation of the PersonImage object.
Which three actions should you perform in sequence to complete the implementation? (Develop the
solution by selecting the required code segments and arranging them in the correct order.)

DRAG DROP
You have the following code:

The web service returns a JSON object that contains two properties named Description and FileName.
The PersonImage object must meet the following requirements:
Create an object that represents an image that will be displayed.
Set the image properties from the values that are returned by the web service.
Expose the image as a property of the PersonImage object.
You need to insert code at line 13 to complete the implementation of the PersonImage object.
Which three actions should you perform in sequence to complete the implementation? (Develop the
solution by selecting the required code segments and arranging them in the correct order.)

Answer: See the explanation.

Explanation:

Box 1: var img = document.createElement(‘img’);
Box 2: img:alt = image.Description;
img src = image.FileName;
Box 3: return this.img;

Note:
* Image Object
The Image object represents an embedded image.
For each <img> tag in an HTML document, an Image object is created.
Notice that images are not technically inserted into an HTML page, images are linked to HTML pages.
The <img> tag creates a holding space for the referenced image.
* Image Object Properties include
alt, Sets or returns the value of the alt attribute of an image
src, Sets or returns the value of the src attribute of an image



Leave a Reply 10

Your email address will not be published. Required fields are marked *


hus

hus

The answer is:

var img = document.createElement(‘img’);
img.alt = image.Description;
img.src = image.FileName;
this.img = img;

conor

conor

which is the last line of code?
this.img = img; OR return this.img;

Lab

Lab

this.img = img: is correct

Sree

Sree

lab Plz explain it

Phil

Phil

retun this.img is wrong coz this.img is not defined at that point. It also doesn’t ask to return the image. You should expose it within the PersonImage object which you do with this.img = img;

Cheers

ффсцф

ффсцф

Even if image will be returned than
img.img is called again!!!!!!!!!!!!!!!!!!!!!!
So it’s totally wrong!

this.img = img is correct

Franco2000

Franco2000

Agreed. I made a html page including the “this.img = img” code and it works, if you use “return this.img” it fails.

Correct answer–> this.img = img

M

M

why shouldn’t it be:

this.img = document.createElement(‘img’);
img.alt = image.Description;
img.src = image.FileName;

Umer Khalid

Umer Khalid

Because as per the question statement we are supposed to CREATE an image object first and then EXPOSE it as property of the PersonImage object. So as per my understanding following answer is correct:

var img = document.createElement(‘img’);
img.alt = image.Description;
img.src = image.FileName;
this.img = img;

d

d

because it should be this.img.alt = … img.alt will set the alt property of the local img variable and not the memberfield in this