Basic JavaScript - Word Blanks

Tell us what’s happening:
Describe your issue in detail here.

So, I noticed that if I write my answer out exactly like the answer given in the help video, the answer is correct, but if I change the order of the const’s, like I did in the example below, the answer is suddenly considered incorrect, even though it is technically correct (assuming there isn’t a typo). Seems to me that there is a hidden condition requiring you to use the const’s in a certain order or am I overlooking something?

Your code so far

const myNoun = "dog";
const myAdjective = "big";
const myVerb = "ran";
const myAdverb = "quickly";

// Only change code below this line
const wordBlanks = "My " + myNoun + "was very " + myAdjective + "but, he " + myVerb + "very " + myAdverb + "."; // Change this line
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Safari/605.1.15

Challenge: Basic JavaScript - Word Blanks

Link to the challenge:

I don’t know much about who and how is writing the tests for the tasks. But, I guess there is a reason for pre-written comments:

1 Like

Sorry, I’m struggling to understand what you’re trying to convey here.

I did actually find a typo! I forgot to leave the space out at the end before the period. e.g. "very " vs. “very” – because there is not a space between a word and a punctuation.

Unfortunately, that did not solve my problem.

I saw in another post something about using something called “result”? Not sure why that is. Perhaps something having to do with using “const”?

You changed part of the code with constants, right?

For tests it is something unexpected, tests confused because of it, they were not written to handle such cases.

That’s why answer is considered incorrect.

There is prewritten comment in the task:

only change code below this line

You changed code above this line.

Okay. I see what you’re saying. So there is like an inherently understood rule that the const’s have to follow the order in which they were listed in the block?

Wait. What? No, I don’t think I did. Where do you see that I changed the code?

You wrote this:

It’s about changing these lines, right?

Changing the order of the consts would we making a change above a comment that says not to make a change above the comment.

No. I got it mixed up. Sorry. What I meant was changing the order of use specifically in my string. So instead of writhing it out like is suggested in the help video, where he uses the const’s out of order, (e.g. “big” “dog”, “ran”, “quickly”), I used them in the order in which they were listed (e.g. “dog”, “big”, “ran”, “quickly”).

Does that make sense?

Yeah, thanks for clarification, I get it

.

this stuff from your original post is failing tests, because there is some spaces which should be added.
It has nothing to do with order of constants.
I just added couple of spaces and it passed.

Yeah, I just messed around order of constants in the string, it doesn’t matter.

Can you paste in your version?

I guess so. From our conversation, I guess you already solved it.

const wordBlanks = "My " + myAdverb + " was very " + myNoun  + " but, he " + myAdjective + " very " + myVerb + ".";
1 Like

I figured it out. I didn’t realize you have to put spaces at the beginning of the non-words. :sweat_smile:

In my defense that was kind of a mind bender. I guess I surmised that there were implied spaces at the end of the const’s?

Well, without these spaces, words will be smashed into each other

const contains only stuff which is assigned to it.

here is no space at the end of assigned value.
JS will not add any spaces just because it wants :upside_down_face:

1 Like