Review wanted for JavaScript 'Silly story generator'

So I finished the “silly story generator” assessment for JavaScript but I don’t think I did it right. I went live with the HTML and it didn’t work the way I was hoping it to. Can someone go over my code and explain to me what I’ve done wrong?

Here’s my editable code:
Link to the assessment page:

Hi @gijutaku23 and welcome to the community :wave:

Good work so far! :tada:

Here are some hints to get you further:

  • replace() doesn’t change the string directly. It returns the new string.
  • There are two occurrences of :insertX:. Maybe have a look at replaceAll().
  • In the second half you used storyText instead of newStory. This needs to be changed.

I hope that helps. Feel free to ask more questions if something isn’t clear enough. :slightly_smiling_face:

Have a nice day,

1 Like

Thank you so much @mikoMK! You’ve really helped me a lot, especially in the first bullet point where you further explained the replace() method to me. That was the biggest issue as to why my code wasn’t working. I went back into the “Useful string methods” article and saw the proper syntax I had to put in. Now my code is fully functioning! Thank you again! :grin: :grin:

1 Like

You’re welcome. I’m glad my hints were helpful.
I had another look at your exercise and now it works properly. :+1:

One more thing to keep in mind for the future:
I recommend using const by default for variable declarations instead of let. It will help preventing accidental variable redeclarations.

1 Like