FreeCodeCamp.com - Basic JavaSript - Word Blanks
Link to FreeCodeCamp
Sollution
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+".";
// Your code above this line
return result;
}
// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.
You will need to use string operators to build a new string,
result
, using the provided variables: myNoun
, myAdjective
, myVerb
, and myAdverb
.
You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.
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.
Sollution
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+".";
// Your code above this line
return result;
}
// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
cut copy paste this code it will work
OdpovědětVymazat/ Only change code below this line
var wordBlanks = "The "+ myAdjective +" "+ myNoun +" "+ myVerb +" "+ myAdverb +" to catch the ball.";// Change this line
console.log(wordBlanks);
// Only change code above this line