Freecodecamp: unclear instructions for basic JavaScript: Appending Variables to Strings lesson

Created on 3 Sep 2020  路  8Comments  路  Source: freeCodeCamp/freeCodeCamp


the instruction says: "Set someAdjective and append it to myStr using the += operator." while it doesn't specify that you should set a string for someAdjective. I find it confusing and I think mentioning this can help newbie coders a lot

Link to the lesson: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings

Tell us about your browser and operating system:

  • Browser Name: chrome
  • Browser Version:
  • Operating System: windows 10

If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):

first timers only help wanted learn

All 8 comments

image

The test text below the instructions does specify the value of someAdjective should be a string. 馃檪

oh ok, I thought eyes might not go there, and just look for direction in the instruction section.

oh ok, I thought eyes might not go there, and just look for direction in the instruction section

I do agree with you @najmieh. Though the test description clarifies what is expected of the learner, I think it makes more sense to be explicit about the type of someAdjective in the task description rather than in the test description. I say this because many other assignments do not specify all the requirements of the task in the task description. You can only be sure of what is expected of you after going through the test description which in my opinion shouldn't be the case.

I have personally fallen victim to this on many occasions. After implementing a solution and pressing the Run the tests button, i sometimes realize i have missed certain requirements of the task which have not been included in the assignment description but are explained in the test description. It would be natural for someone to implement a solution immediately after reading the exercise and then make a submission. Even the mere fact that Run the tests button is just beneath the assignment description is indirectly telling the learner to implement a solution and submit. In my opinion, we shouldn't defer certain details of an exercise to test description because it is time-wasting for a learner to implement a solution and then fail the test because s/he has omitted some details which exist in the test description.

How about:

Set `someAdjective` to a string that will complete the sentence below it. Then, append the variable to `myStr` using the `+=` operator.

I know it doesn't say "3 characters long" in there, but that made it feel a little robotic.

I think a small rewrite of the instructions would be fine on this one, so I will open it up for a PR. We can work out the details of what exactly it should say on the PR. I vote for my suggestion, but other suggestions are certainly welcome.

Hi @moT01 .

I know it doesn't say "3 characters long" in there, but that made it feel a little robotic.

Is the instruction complete without specifying what the length of the string should be? Essentially if the string is not at least three characters long, the test will fail. Something along the lines of "Set someAdjective to a string at least 3 characters long and append it to myStr using the += operator" would be exhaustive IMHO.

Here is another approach to this. Why not supply a list of say 5 adjectives the user can choose in the instructions:

Assign someAdjective one of the following values and then append it to myStr using the += operator.
fun, boring, difficult, great, tiring

Then the test could be something like:

assert(typeof someAdjective !== 'undefined' && /fun|boring|difficult|great|tiring/i.test(someAdjective.trim()));

The above regex will handle any case of the words, ignores extra before or after white space, and ignores added punctuation.

Hi @nibble0101

"Set someAdjective to a string at least 3 characters long and append it to myStr using the += operator".

I agree with you, it's a good TODO description.

Was this page helpful?
0 / 5 - 0 ratings