Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

2.6 KiB

title
title
Word Blanks

Word Blanks


Problem Explanation

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 below //Your Code here and up to //Change this line.
  • Take note that you are editing the inside of the wordBlanks() function.
  • You will have basically created a sentence with the provided string variables.

Hints

Hint 1

+ can be used for concatenating strings.

Hint 2

Just as you can chain strings by concatenating, you can assign them to an existing variable instead of a new one.

Hint 3

+= will allow you to use an existing variable, a string type in this case. Remember to add your own non-letters in between each variable.


Solutions

Solution 1 (Click to Show/Hide)
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");

Example Run

  • Test wordBlanks("dog", "big", "ran", "quickly"); runs.
  • Variable result is declared with an empty string "".
  • result will be changed with a new 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.
  • result is returned.

Code Explanation

  • Use result to concatenate the given variables.
  • Separate words with whitespace and appropriate words to form the full sentence.