What am I doing wrong in this Basic Js problem?

Tell us what’s happening:

I don’t understand the instructions with this problem

Your code so far


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

// Only change code below this line
var wordBlanks = "myNoun" + "myVerb" + "myAdjective" + "myAdverb"; // Change this line
// Only change code above this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Word Blanks

Link to the challenge:

Try console.log()ing your wordBlanks. You have jammed your words together without spaces.

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

// Only change code below this line
var wordBlanks = console.log("myNoun " + "myVerb " + "myAdjective " + "myAdverb "); // Change this line
// Only change code above this line

is this good?
edit: not working!

No, when you are console.log()ing something, you don’t need to declare it as a variable. It is predefined as a function in JavaScript, so you can just type it. Also, when you are trying to console.log() a variable, you DON’T use the " ", You just call it’s name. ex:

var variable1 = "hello world";

console.log(variable1); //This will output "hello world" in the console

A lot of times, you want to combine multiple variable to the log, you can easily do this by using the + operator. Ex:

var variable1 = "hello";
var variable2 = "world";

console.log(variable1 + variable2); //outputs "helloworld"
//you can also add spaces by doing these
console.log(variable1 + " " + variable2); //outputs "hello world"
                                    ↑//as you can see there is a space here

in that case objective 1 and 4 are not completed

In your case

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

// Only change code below this line
var wordBlanks = "myNoun" + "myVerb" + "myAdjective" + "myAdverb"; // Change this line
console.log(wordBlanks);
// Only change code above this line

will help you see what’s going on.

1 Like

Thanks I get it now. when were we introduced to console.log() in this course btw. I really need to brush up that chapter!

you will need to remove console.log() from this line: and remove the double quotes from the variables.

var wordBlanks = console.log("myNoun " + "myVerb " + "myAdjective " + "myAdverb "); 

and then add console.log() to wordBlanks
console.log( wordBlanks ); // to see result.

2 Likes

It’s taught in a later part of the JS curriculum. Specifically in the Debugging section. Here’s the link to it

1 Like

why remove the double qoutes?

thank you, sir! But I better go with the order

because you wont be able to display the result in var wordBlanks just like @Catalactics metioned. its a better way for code standards. Thats another way of doing it.

1 Like

Thanks for all your help! I will have to practice more ,i think.

Here since you already manage to understand i will have snipped code of the problem. this way will be much better of doing it. This is called concatenate. I like the ES5 syntax but ES6 makes it more easy to read and understand, but will be good to learn from the bare bones :slight_smile:

var myNoun = "dog";
var myAdjective = "big";
var myVerb = "ran";
var myAdverb = "quickly";
// Only change code below this line
// creating the wordBlanks, and adding the variables with spaces ( + ' ' + )
var wordBlanks = myNoun + ' ' + myVerb + ' ' + myAdjective + ' ' + myAdverb; // Change this line
// Only change code above this line
console.log(wordBlanks);
1 Like

I found these in another thread @JeremyLT @Catalactics @imendieta

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

var wordBlanks = "The " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb + "."; // Only change this line;

Yes, it’s the same code as we explained, but at the start of the string, the user added "The " that means it’s going to output as follows:

The big dog ran quickly.

1 Like

var myNoun = “dog”;
var myAdjective = “big”;
var myVerb = “ran”;
var myAdverb = “quickly”;

//here is my answer
//I have the other way to answer your problem question above. I also can remove the //var if testing from code camp editor.

var myAnswer = “My”.concat(myAdjective, ’ ‘, myNoun,’ ‘,myVerb,’ ',myAdverb );
console.log(myAnswer);

// Only change this line;