freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

Challenge: Word Blanks should have tests to make sure campers use function parameters

Open sludge256 opened this issue 10 years ago • 11 comments

A low priority/bike shedding issue, but I figured it's worth mentioning anyways.

Supplied code passes, but defeats the purpose of the challenge. It's unlikely that someone would ever do this, but I do recall seeing similar code being posted in one of the Gitter rooms.

Challenge Word Blanks

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = "dog big ran quickly cat little hit slowly";

  // Your code above this line
  return result;
}

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

The code I saw in chat looked something like this (from what I remember at least):

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "dog big ran quickly ";
  // Your code below this line
  result += "cat little hit slowly";

  // Your code above this line
  return result;
}

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

sludge256 avatar Mar 17 '16 22:03 sludge256

Hahaha, I love this. It's not something we could ever fully prevent, but we could make it more annoying by adding 2 or 3 more tests. However, I tend to be of the mind that it doesn't matter. If someone does this there's no way they can't realize they're circumventing the purpose of the challenge and since this challenge isn't required for a cert the only thing they're harming is their own learning potential.

Anyone else have thoughts on if this is worth fixing?

arialaurel avatar Mar 18 '16 05:03 arialaurel

@sludge256 @ltegman Isn't this similar to #7600 of intentionally trying to pass the tests?

raisedadead avatar Mar 18 '16 10:03 raisedadead

@raisedadead Yes, that's why I brought it up.

I also agree that it's not a big issue. I can go ahead and close this, and maybe 7600 if we don't plan on preventing such code any time soon.

sludge256 avatar Mar 18 '16 16:03 sludge256

I would like to know what I am supposed to learn from this. Could you help me understand why the above code was controversial. I also noticed there was no closing } at top of page it is a must in java script right. I get an error when I try to place the code. Can anyone help me understand.

jowright avatar Mar 20 '16 17:03 jowright

@jowright This challenge is meant to be an exercise in string concatenation using variables. This concept was introduced in Constructing Strings with Variables.

The above code is controversial because it passes without following the instructions:

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

None of the provided variables were used.

The closing } for the function is just below the return statement.

alistermada avatar Mar 21 '16 00:03 alistermada

I don't quite understand what's being asked of me.

juniorveasy avatar Apr 05 '16 23:04 juniorveasy

Closing. Please refer comment here

raisedadead avatar Apr 20 '16 11:04 raisedadead

result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+"."; it's so funny :santa:

Toriki07 avatar Jul 16 '16 22:07 Toriki07

First of all the challenge itself is not clear with poorly framed and confusing question. Despite reading multiple times I don't understand what the question expects. Can the FreeCodeCamp look after this question and change it? 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.

result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+".";

Bhargavbonu avatar Aug 05 '16 14:08 Bhargavbonu

@Bhargavbonu please open a fresh issue.

raisedadead avatar Aug 05 '16 14:08 raisedadead

removed solution by mod

siguniang avatar Dec 29 '16 10:12 siguniang