Javascript "Word Blanks" challenge issue + main problem with FCC

I feel like this challenge is not clear enough and is introducing concepts that were not used before. Correct me if I’m wrong, but isn’t the bottom “wordBlanks” variable an object? How about the function?
It was not clear to me if I had to use something like wordBlanks = adding the variables to create the sentence or use result variable. Why even declare result initially as =""? And then, why is wordBlanks at the bottom. How does Javascript execute this? The function first and then replaces the words with the ones at the bottom? Many things that leave room to interpretation. You are taking a beginner, introducing him into variables, operators, strings and then jump into function and objects.

I mean it’s really frustrating because thank god I have 4 lessons where I have to type like a first grader every operator out there (I get that += does the opposite of -=, no need for separate lesson for these), but I’m somehow supposed to know suddenly function and what result="" does.

I think some refinements in challenges would really help. This specific lesson also does not have a proper target/goal/end request.

1 Like

Correct me if I’m wrong, but isn’t the bottom “wordBlanks” variable an object?

I’m not sure I understand what you mean. I see no objects there and didn’t use any in my answer. (Unless you want to get nitpicky and point out that in JS, functions are objects.) I think you are referring to the function call.

Why even declare result initially as =“”?

It is common to declare something as an empty string and then append to it. I do this from time to time.

And then, why is wordBlanks at the bottom. How does Javascript execute this?

A function declaration is different from it’s calling. If I declare a function:

function myFunc() {
  console.log("Howdy, parder!");
}

This does nothing but allocated some memory with some instructions in it. In order to get it to do something, I need to call it:

function myFunc() {
  console.log("Howdy, parder!");
}

myFunc(); 

or if I want to pass a parameter:

function myFunc(name) {
  console.log("Howdy, " + name + "!");
}

myFunc("pardner"); 

This is the same schema as “Word Blanks”.

but I’m somehow supposed to know suddenly function and what result=“”

It is unfortunate that the section “Write Reusable JavaScript with Functions” comes after. I can’t remember if functions are ever encountered before that. If they weren’t then that is unfortunate and maybe it will get addressed in the beta. I’m sure you can find a youtube video by searching “javascript functions”. The basic concept is not hard, but I understand if it was a shock.

As to result="", that is just creating a blank string to which you can add things. For example:

var myString = "";    // declared as an empty string, nothing in it

for (var i = 10; i > 0; i--) {
  myString += i + ", ";
}
myString += "BLAST OFF!!!";

console.log(myString);

// output -> 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, BLAST OFF!!!

This is a common thing to do. Why do var myString = ""; instead of just var myString;? That way I know it is a string value and will be treated as such. Often it wouldn’t matter. But imaging if, for some strange reason, I needed to do something like this:

var myString;    // declared as an empty string, nothing in it

for (var i = 10; i > 0; i--) {
  myString += i
  myString += ", ";
}
myString += "BLAST OFF!!!";

console.log(myString);

// output -> NaN, 9, 8, 7, 6, 5, 4, 3, 2, 1, BLAST OFF!!!

Notice that there is no “10”, it is NaN (or Not a Number), when we got there the first time, it didn’t know what myString was. Is it a number? Is it a string? JS has to know this to know how to treat it. When we get to myString += ", ";, JS goes Ah ha! It now assumes it’s a string because you are trying to add (concatenate) a string to it. All of this confusion could have been avoided if I’d used var myString = "";

JS is a little light and loose with how it treats data types (compared to other languages where this would never be an issue) so it is always good to be extra cautious.

Yes, fCC can be a little frustrating. Yes, you will be hit with a new challenge that you feel that fCC has not prepared you for (I’m on the back end section and just got hit with a big one.) But remember that as a programmer, that is how it works. Even the best programmer in the world does not know everything. And new frameworks keep getting added at an alarming rate. There will be assignments where you will be asked to do something and you won’t even know where to start. Learn to research. Learn to ask. And remember that we are here to help you.

5 Likes

Hi Aysun,

@ksjazzguitar has given a great answer! So I will just add some thoughts.

The longer I bang my head against problems like you are having, the better I get at googling, searching StackOverflow and reading the MDN docs. This is the number one skill that I have taken from FCC - knowing where to look for answers. As you learn more jargon, you will get better at looking for answers, which will teach you more jargon, and the cycle continues.

I understand that it is frustrating, and that it is a lot to learn all at once. I felt and feel the same way.
But that is how it is!
I recently started my first coding job and 90% of the time I don’t know what is happening and am completely lost. I try to turn the frustration into curiosity.
When I started learning I would have freaked out in this situation instead of been curious, but now I have become good at finding answers. I don’t panic and I eventually find them. And every investigation teaches me something.

The challenge is ok I think, the goal is to pass the test cases. The REAL challenge is learning to find the answers to your questions, and then reading up about why those are the answers. We are here to help, but we will sometimes be wrong. The MDN docs will never be wrong!
It will get better!

4 Likes

Thanks to both of you for your replies and to @ksjazzguitar for the time put in to write a great explanation.
My problem is not understanding JS, but with FCC and the lessons.

As I previously mentioned in my first post, I see no logic behind in making separate challenges for some operators, while you have a challenge that dives in directly into more complex things without explaining other things before. On top of it all, this specific challenge has no clear instruction or request from the end user.

So what I’m trying to say is that FCC challenges could use some polishing and if FCC wants to go big, this is something that is not negligible. The moment we start taking things as they are is the moment progress stops.

Right, but you also have to understand that what may seem difficult to you might be intuitive for someone else, and vice versa. And breaking operats into smaller sectitions may make it easier for some people to digest. Unfortunately some things can’t be broken down.

But they are currently beta testing they he next revision of fCC. Perhaps some of your issues are being addressed. And you can address them yourself on the github account.

Sometimes I lose confidence in myself because my knowledge is weak but having people like you is putting things back to the right place