* feat(curriculum): Add Basic JS Scrimba links * Fix: Add missing video url. * fix: update videoUrl
3.8 KiB
3.8 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 result
variable.
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 return a string.
testString: assert(typeof wordBlanks("","","","") === 'string', '<code>wordBlanks("","","","")</code> should return a string.');
- text: <code>wordBlanks("dog", "big", "ran", "quickly")</code> should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
testString: assert(/\bdog\b/.test(test1) && /\bbig\b/.test(test1) && /\bran\b/.test(test1) && /\bquickly\b/.test(test1),'<code>wordBlanks("dog", "big", "ran", "quickly")</code> should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).');
- text: <code>wordBlanks("cat", "little", "hit", "slowly")</code> should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
testString: assert(/\bcat\b/.test(test2) && /\blittle\b/.test(test2) && /\bhit\b/.test(test2) && /\bslowly\b/.test(test2),'<code>wordBlanks("cat", "little", "hit", "slowly")</code> should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).');
Challenge Seed
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
// Your code below this line
var result = "";
// Your code above this line
return result;
}
// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
After Test
var test1 = wordBlanks("dog", "big", "ran", "quickly");
var test2 = wordBlanks("cat", "little", "hit", "slowly");
Solution
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
result = "Once there was a " + myNoun + " which was very " + myAdjective + ". ";
result += "It " + myVerb + " " + myAdverb + " around the yard.";
return result;
}