What is wrong in my code.. i m sorry I am totally new to coding stuff

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = “”;
// Your code below this line
myNoun=“dog”;
myAdjective=“big”;
myVerb=“ran”;
myAdverb=“quickly”;

result = “My " + myNoun+ " is” + myAdjective + "a "+ myVerb+ " hero " + myAdverb + " ";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks(“dog”, “big”, “ran”, “quickly”);

Your code will always return the string "My dog isbiga run hero quickly ". Aside from the fact that the sentence isn’t grammatical, it returns the same result regardless of the arguments passed in, because it’s using the variables you’ve set within the function rather than those arguments.

I tried your code and had issues with some of your quotes. Im not sure if they were copied from somewhere else, but I deleted your quotes that didnt work and put in new ones. Here is the code, as you have it, working. but you will still need to account for lionel-rowe’s advice.

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

result = "My " +myNoun+ " is " +myAdjective+ " a "+ myVerb+ " hero " + myAdverb + " ";

Needs wrapping in backticks.


```
Triple backticks for pasting multiline code
```

The main issue is you were using instead of " your odd quote symbol wasn’t recognized by Javascript and caused the issue. Correct example:

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun="dog";
myAdjective="big";
myVerb="ran";
myAdverb="quickly";

result = "My " + myNoun + " is " + myAdjective + " a " + myVerb + " hero " + myAdverb + " ";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Hope this helped :slight_smile:

Again, it’s all about the backticks. Discourse forums automatically convert straight quotes to curly quotes unless they’re explicitly marked up as code. It’s unlikely anyone’s actually typing it into the code editor like that (though input methods for e.g. Chinese could potentially cause similar mistakes if you’re not careful).

1 Like