We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.
- Change the code on the line with the comment
//Change this line.
- You will have basically created a sentence with the provided string variables.
- Mad Libs
- Challenge: Constructing Strings with Variables
- Challenge: Concatenating Strings with Plus Operator
- Challenge: Concatenating Strings with the Plus Equals Operator
+ can be used for concatenating strings.
Just as you can chain strings by concatenating, you can assign them to an existing variable instead of a new one.
Remember to add your own non-letters in between each variable.
Solution 1 (Click to Show/Hide)
var myNoun = "dog"; var myAdjective = "big"; var myVerb = "ran"; var myAdverb = "quickly"; var wordBlanks = "The " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb + "."; // Only change this line;
- wordBlanks will be changed to string composed of the concatenated strings “dog”, “big”, “ran”, “quickly” through the variables myNoun, myAdjective, myVerb, myAdverb respectively; the order is changed and whitespace added.
- Use wordBlanks to concatenate the given variables.
- Separate words with whitespace and appropriate words to form the full sentence.