Skip to content

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

Open
sludge256 opened this Issue · 6 comments

5 participants

@sludge256

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");
@ltegman
Free Code Camp member

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?

@ltegman ltegman added the Discussing label
@raisedadead
Free Code Camp member

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

@sludge256

@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.

@ghost

This is not me. Do not own a Mac. Connect with cell phone only

@jowright

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.

@alistermada

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.