* fix: convert js algorithms and data structures * fix: revert some blocks back to blockquote * fix: reverted comparison code block to blockquotes * fix: change js to json Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: convert various section to triple backticks * fix: Make the formatting consistent for comparisons
3.7 KiB
3.7 KiB
id, title, challengeType, videoUrl
id | title | challengeType | videoUrl |
---|---|---|---|
56533eb9ac21ba0edf2244bb | Word Blanks | 1 | https://scrimba.com/c/cP3vVsm |
Description
var sentence = "It was really " + "hot" + ", and we " + "laughed" + " ourselves " + "silly" + ".";
Instructions
+
to build a new string, using the provided variables: myNoun
, myAdjective
, myVerb
, and myAdverb
. You will then assign the formed string to the wordBlanks
variable. You should not change the words assigned to the variables.
You will also need to account for spaces in your string, so that the final sentence has spaces between all the words. The result should be a complete sentence.
Tests
tests:
- text: <code>wordBlanks</code> should be a string.
testString: assert(typeof wordBlanks === 'string');
- text: You should not change the values assigned to <code>myNoun</code>, <code>myVerb</code>, <code>myAdjective</code> or <code>myAdverb</code>.
testString: assert(myNoun === "dog" && myVerb === "ran" && myAdjective === "big" && myAdverb === "quickly");
- text: You should not directly use the values "dog", "ran", "big", or "quickly" to create <code>wordBlanks</code>.
testString: const newCode = removeAssignments(code); assert(!/dog/.test(newCode) && !/ran/.test(newCode) && !/big/.test(newCode) && !/quickly/.test(newCode));
- text: <code>wordBlanks</code> should contain all of the words assigned to the variables <code>myNoun</code>, <code>myVerb</code>, <code>myAdjective</code> and <code>myAdverb</code> separated by non-word characters (and any additional words in your madlib).
testString: assert(/\bdog\b/.test(wordBlanks) && /\bbig\b/.test(wordBlanks) && /\bran\b/.test(wordBlanks) && /\bquickly\b/.test(wordBlanks));
Challenge Seed
var myNoun = "dog";
var myAdjective = "big";
var myVerb = "ran";
var myAdverb = "quickly";
var wordBlanks = ""; // Only change this line;
const removeAssignments = str => str
.replace(/myNoun\s*=\s*["']dog["']/g, '')
.replace(/myAdjective\s*=\s*["']big["']/g, '')
.replace(/myVerb\s*=\s*["']ran["']/g, '')
.replace(/myAdverb\s*=\s*["']quickly["']/g, '');
Solution
var myNoun = "dog";
var myAdjective = "big";
var myVerb = "ran";
var myAdverb = "quickly";
var wordBlanks = "Once there was a " + myNoun + " which was very " + myAdjective + ". ";
wordBlanks += "It " + myVerb + " " + myAdverb + " around the yard.";