Build a Sentence Maker

Please my code isn’t passing this section “24. You should use the correct story format for the second story: “Once upon a time, there was a(n) [adjective] [noun] who loved to eat [noun2]. The [noun] lived in a [place] and had [adjective2] nostrils that blew fire when it was [verb].”. Pay attention to spaces.”

I have crosschecked spacing and spellings and nothing seems to be wrong with the code. Here is the code:

{

let adjective = “beautiful”;

let noun = “girl”;

let verb = “hot”;

let place = “hut”;

let adjective2 = “large”;

let noun2 = “Pretzels”;

let firstStory = "Once upon a time, there was a(n) " + adjective + " " + noun + " who loved to eat " + noun2 + ". The " + noun + " lived in a " + place + " and had " + adjective2 + " nostrils that blew fire when it was " + verb + “.”;

console.log("First story: " + firstStory);

}

{

let adjective = “huge”;

let noun = “ogre”;

let verb = “hungry”;

let place = “cave”;

let adjective2 = “angry”;

let noun2 = “little rabbits”;

let secondStory = “Once upon a time, there was a(n)” + adjective + noun + " who loved to eat " + noun2 + “.” + “The " + noun + " lived in a " + place + " and had” + adjective2 + "nostrils that blew fire when it was " + verb + “.”;

console.log("Second story: " + secondStory)

}

What about this?

You can actually use the same string concatenation for both stories since the only thing that is changing is the variable values.

I’ve done that but it’s still not working

Please post your updated code if you need more help.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Here’s the code:

{
  let adjective = "beautiful";
  let noun = "girl";
  let verb = "hot";
  let place = "hut";
  let adjective2 = "large";
  let noun2 = "Pretzels";

  let firstStory = "Once upon a time, there was a(n) " + adjective + " " + noun + " who loved to eat " + noun2 + ". The " + noun + " lived in a " + place + " and had " + adjective2 + " nostrils that blew fire when it was " + verb + ".";
  console.log("First story: " + firstStory);
}

{
  let adjective = "huge";
  let noun = "ogre";
  let verb = "hungry";
  let place = "cave";
  let adjective2 = "angry";
  let noun2 = "little rabbits";

  let secondStory =
    "Once upon a time, there was a(n) " + adjective + " " + noun +
    " who loved to eat " + noun2 + ". " +
    "The " + noun + " lived in a " + place +
    " and had " + adjective2 + " nostrils that blew fire when it was " + verb + ".";

  console.log("Second story: " + secondStory);
}
```

why do you have those {}?

Because I can’t redeclare a let variable in the same block, without it, my code shows errors

So I removed the curled brackets and redeclared my let variables in the second story but without the “Let”

let adjective = "beautiful";
  let noun = "girl";
  let verb = "hot";
  let place = "hut";
  let adjective2 = "large";
  let noun2 = "Pretzels";

  let firstStory = "Once upon a time, there was a(n) " + adjective + " " + noun + " who loved to eat " + noun2 + ". The " + noun + " lived in a " + place + " and had " + adjective2 + " nostrils that blew fire when it was " + verb + ".";
  console.log("First story: " + firstStory);



   adjective = "huge";
   noun = "ogre";
   verb = "hungry";
   place = "cave";
   adjective2 = "angry";
   noun2 = "little rabbits";

  let secondStory =
    "Once upon a time, there was a(n) " + adjective + " " + noun +
    " who loved to eat " + noun2 + ". " +
    "The " + noun + " lived in a " + place +
    " and had " + adjective2 + " nostrils that blew fire when it was " + verb + ".";

  console.log("Second story: " + secondStory);
```

Here’s the result I got from this code;

“// running tests 25. You should assemble your second story using the variables you declared in the correct order. // tests completed // console output First story: Once upon a time, there was a(n) beautiful girl who loved to eat Pretzels. The girl lived in a hut and had large nostrils that blew fire when it was hot. Second story: Once upon a time, there was a(n) huge ogre who loved to eat little rabbits. The ogre lived in a cave and had angry nostrils that blew fire when it was hungry."

I’ve fixed it, thanks for your help

you managed to fix the format of the second story too? great job!

Yes, thank you

Was a little spacing problem