I took a look at the solution, which is similar to mine but does a concatenation operator at the end with the blank string at the top, and also uses the += operator instead of +. I don’t completely understand these changes, or why my code fails.
I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
You have three problems:
JavaScript is case-sensitive, so make sure you type each variable the same throughout your code. For example, myNoun is not the same as MyNoun.
One you resolve the typos, you need to understand that since MyNoune and myAdverb are variables, you do not want " before or after them.
Resolving 1 and 2 above will still reveal one final problem. WordBlanks needs to be a sentence and sentences have spaces between the words. You just need to concatenate " " between each variable.
You don’t need to set up any new variables (just use result). All of the variables should be passed in using the arguments of the function.
Your function should be something like this:
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { // These are your variables
// They're set as whatever arguments you pass in to the function
// Don't assign new variables with the same name within the function,
// or you'll break it.
var result = "";
/* Here, you build up `result` into a sentence.
You can either reassign `result` as the full sentence
using `+` to concatenate, or build it up step by
step using `+=` */
return result;
}
Examples of + vs +=
var a = '';
var b = '';
var c = ',';
var d = '!';
a = 'Hello' + c + ' World' + d; // reassigns `a`
b += 'Hello';
b += c;
b += ' World';
b += d; // building up `b` step-by-step
a; // "Hello, World!"
b; // "Hello, World!"
a === b; // true