Word Blanks alternative solution

Tell us what’s happening:

Hey guys, how’s it going?

I was able to complete the Word Blanks challenge but after comparing the solution’s code with mine, couldn’t help but too feel mine was bad. I was wondering if anyone had suggestions on the thought process used to implement the better version when solving the challenge. Thanks.

Your code so far

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "sentence";
  // Your code below this line
  result = "The " + "little " + "smelly cat " + "hit " + "the big " + "dog " + "slowly " + "and then quickly " + "ran into the house";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/word-blanks

I am actually surprised the tests were not better written, because your solution should never have passed. You are not even using the arguments which was the whole point of the challenge. The thought process to create a better solution is make use of the myNoun, myAdjective, myVerb, and myAdverb argument values which are passed in with the various calls to the function in the tests. You should not be hardcoding the values you are trying to pass into the function. All you needed to do was supply some extra strings (like “The " and " into the house.” and concatenate them with the myNoun, myAdjectie, myVerb, and myAdverb values to create actual sentence strings.

1 Like

Hey Randell,

Thanks for your time and feedback, I really appreciate it.