Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 3: Requirement # Requirements Explain the below code. Include the final

ID: 3714511 • Letter: P

Question

Problem 3:


Requirement # Requirements


Explain the below code. Include the final output to console.log().


Tip: Higher Order Function (Callback).


function Thing(name) {


this.name = name;


}


Thing.prototype.doSomething = function(callback, salutation) {


callback.call(this, salutation);


}


function Afunction(salutation) {


console.log(salutation + " " + this.name);


}


var t = new Thing('John Smith');


t.doSomething(Afunction, 'Hello');


Problem 4:


Requirement # Requirements


What are the advantages of using Objects in JavaScript. Min 50 words


Submit Answer


Problem 5:


Requirement # Requirements


Create a an Object constructor function called MedRecord with the properties firstName, lastName, medRecord, medID, insuranceInfo.


Define a MedRecord prototype method called changeInsurance() that accepts the name of a patient new insurance information and update object insuranceInfo property.


Problem 6:


Requirement # Requirements


Put the below data in a JSON formatted array where each individual is its own object. Then write code that will print each person's first letter of their first name and last name (example: msmith)


firstName: Mike lastName: Smith


firstName: Anna lastName: House


firstName: Mark lastName: McDonald

Explanation / Answer

Solving first question as per chegg policy

Problem 3:

Requirement # Requirements

Explain the below code. Include the final output to console.log().

Tip: Higher Order Function (Callback).

function Thing(name) {this.name = name;} // This is function declaration, function with name thing

Thing.prototype.doSomething = function(callback, salutation) {callback.call(this, salutation);} // This is adding one more function doSomething to Thing. doSomething take another function as argument and a salutation

function Afunction(salutation) {console.log(salutation + " " + this.name);} // this is function delcaration which print saluation to console

var t = new Thing('John Smith'); // this is declaration of object of type Thing (class in js are functions)

t.doSomething(Afunction, 'Hello'); // this is calling something to print Hello John Smith

This willl print Hello John Smith

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote