Question: 6.5.1: Functions. Assign a variable madLib to a function expression that has five parameters in the order: two nouns, an adjective, an adverb and a
6.5.1: Functions.
Assign a variable madLib to a function expression that has five parameters in the order: two nouns, an adjective, an adverb and a verb. The function should return a mad lib string value by substituting the parameter values into the following template: The [adjective] [noun1] [adverb] [verb] the [noun2]. For example: madLib("dog", "moon", "lazy", "quietly", "smashed") returns "The lazy dog quietly smashed the moon.".
/* Your solution goes here */
/* Code will be tested once with parameters: "dog", "moon", "lazy", "quietly", "smashed", and again with parameters: "rat", "city", "bored", "gently", "became" */ console.log(madLib("dog", "moon", "lazy", "quietly", "smashed"));
______________________________________________________________________
6.6.1: Arrays.
Multiply each element in sourceArray with the corresponding value in offsetAmount. Store each value in a new array named destinationArray.
var sourceArray = [ 40, 50, 60, 70 ]; // Tests will use different arrays var offsetAmount = [ 2, 5, 8, 4 ]; // Tests will use different arrays var destinationArray = [];
/* Your solution goes here *
______________________________________________________________________
6.8.1: Strings.
Use indexOf(), and substr() or substring(), to display the end of the sentence starting from the word "make".
var oldSaying = "Two wrongs don't make a right."; // Code will be tested with "Did you make that robot?"
/* Your solution goes here */
______________________________________________________________________
6.8.2: Using Date methods.
Display the date when Facebook's website launched in M-DD-YYYY format. Ex: The 31st of January 1970 should be displayed as: "1-31-1970".
var interestingEvents = { "Long distance telegraph": new Date(1844, 4, 24), "First telephone call": new Date(1876, 2, 10), "Microsoft founded": new Date(1975, 3, 4), "World wide web born": new Date(1989, 2, 1), "Google founded": new Date(1998, 8, 4), "Facebook website launch": new Date(2004, 1, 4) }; var interestingDate = interestingEvents["Facebook website launch"]; // Code also tested using date of First telephone call
/* Your solution goes here */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
