Assign a variable madLib to a function expression that has five parameters in the order: an adverb, two nouns, an adjective 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("quietly", "dog", "moon", "lazy", "smashed") returns "The lazy dog quietly smashed the moon.". 1 2 3 4 5 6 7 /* Your solution goes here */ /* Code will be tested once with parameters: "quietly", "dog", "moon", "lazy", "smashed", and again with parameters: "gently", "rat", "city", "bored", "became" */ console.log(madLib("quietly", "dog", "moon", "lazy", "smashed")); 1 2 3 4 Check Next 1

Answer :

MrRoyal

Answer:

The function is written in C++:

void madLib(string adjective,string noun1,string adverb,string verb,string noun2){

   cout<<"The "+verb+" "+noun1+" "+adjective+" "+noun2+" the "+adverb;

}

Explanation:

This line defines the function

void madLib(string adjective,string noun1,string adverb,string verb,string noun2){

This line generates and returns the output string

   cout<<"The "+verb+" "+noun1+" "+adjective+" "+noun2+" the "+adverb;

NB: I've added the full source code as an attachment where you can test various input strings

${teks-lihat-gambar} MrRoyal