Problem 2: Requirement # Requirements var myQuote=\"He who laughs, lasts.\"; Giv
ID: 3714456 • Letter: P
Question
Problem 2:
Requirement # Requirements
var myQuote="He who laughs, lasts.";
Give the value of each of the following expressions:
a. myQuote.toUpperCase()
b. myQuote.indexOf("a")
c. myQuote.indexOf("@", 1)
d. myQuote.indexOf("who")
e. myQuote.indexOf("a", 10)
f. myQuote.lastIndexOf("a")
g. myQuote.lastIndexOf("a", 7)
h. myQuote.lastIndexOf("a", 10)
i. myQuote.charAt(7)
j. myQuote.charAt(myQuote.length)
k. myQuote.charAt(myQuote.length - 3)
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
Problem 2:
var myQuote="He who laughs, lasts.";
Give the value of each of the following expressions:
a. myQuote.toUpperCase()//Convert the string to upper case letters
HE WHO LAUGHS, LASTS.
b. myQuote.indexOf("a")//Returns the position of the first occurrence of a specified value in a string.
ans: 8
c. myQuote.indexOf("@", 1)//@ is not found in the myQuote
ans:-1
d. myQuote.indexOf("who")
ans:3
e. myQuote.indexOf("a", 10)//From 10th position onwards search of "a" begins. In 16th position we found "a"
ans: 16.
f. myQuote.lastIndexOf("a")//Search a string for the last occurrence of "a"
ans: 16
g. myQuote.lastIndexOf("a", 7)//not found "a" in the string of first 7 characters.
ans:-1
h. myQuote.lastIndexOf("a", 10)// found in "laughs"
ans:8
i. myQuote.charAt(7)// returns the character at the specified index in a string.
ans: l
j. myQuote.charAt(myQuote.length)// myQuote.length returns the length of the string i.e 21. charAt(21) returns nothing.
ans: nothing returns.
k. myQuote.charAt(myQuote.length - 3)
//here length is 21-3 i.e 19 charAt(19)
ans:t
Dear According to Chegg one can answer only one question.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.