JavaScript String Concatenation - wordBlank

First, I found a thread on this topic, but it was closed and did not address the issues that I want to ask about. I hit the wall trying to find my error on this exercise. I’m posting images instead of code because posting code doesn’t allow me to draw attention to specifics. I can highlight things in images. I understand that posting actual code is preferred but has its limits, IMO.

Buckle up. This might take a while.


In this screenshot I copied the instructions which I think are less than clear. I inferred, though the instructions didn’t say so, that I would have to declare variables - sentence and wordBlanks - because they didn’t exist in the code given. Did I misunderstand what was meant? I thought I was to compose a proper sentence using constants provided. In order to do so I had to define a place to put it (const = "sentence"). Because the instructions say to assign that sentence to workBlanks. I think I did that using all of the constants - adjective, noun, verb, adverb and allowing for spaces between them as I point out in the next screenshot.


You will note at the lower left that the big “X” is my error. But what did I do wrong? First, I underlined in blue the declarations for the sentence and for the variable wordBlank and the code to set them the same. Next, I underlined in blue where I used each of the given constant values in constructing the sentence. Then drew green boxes around the areas that I left for spaces between the words. I even put a green box around the end of the sentence to show that I didn’t insert an unneeded space before the period.

I’ve looked at syntax until I can’t see it any more. I’ve looked at spelling and punctuation forwards and backwards. No doubt I’ve made a simple and stupid error, but I can’t find it despite the time I’ve spent looking at it and reading other articles on the web on the subject of js concatenation of strings.

I apologize for being verbose, but I didn’t know how else to convey what I’ve done and how I’ve struggled to find my error.

ps: why don’t the " ```" marks work in this post?

This variable is in the given code next to a comment telling you where to make changes. Its on line 7 of your picture. You shouldn’t make any new variables the instructions don’t ask for.

There are other problems with your code that are easier to discuss with your actual code.

I tried using that wordBlanks to build the sentence but still got errors. I inferred that part of the lesson was to make me realize that variables had not been declared.

Ignoring that I misunderstood the exercise, is there anything wrong with my code other than it was not what the exercise expected? Would it not run? Yes, there is good code and bad code, but I’m trying to learn here. I will have to return to the lesson and reset it, but IIRC there was no wordBlanks in the exercise code before I put it there.

Please post your code.

You have several issues, to include

  1. you must only use wordBlanks and not your new variable
  2. you cannot put quotes around the variable names

It was there

Yes, I was just coming back to report that I was mistaken. That should give you some idea of how long I struggled with what should have been a very easy exercise.

I should have reset the lesson between each attempt. That would be a good thing to tell students because its easy to get lost in one’s changes.

Its normal to get things mixed up. Learning is hard.

It’s especially hard at 81. :roll_eyes: