Silly_story_generator home work

Hi guys!
I’m back, I began to learn JS three weeks ago. I found it’s hard for me,
First time I do the home work and I even don’t understand what does the code meaning, so I read the pages more times , do more practise.
Now you see it’s my work.
Silly_story_generator

Hi @sjmcsy

Well done! Everything works as expected. :smiley:

I have two remarks:

  • Instead of using two times newStory = newStory.replace(':inserta:' , xItem); you could also use newStory = newStory.replaceAll(':inserta:',xItem); once. It’s a newer JS function, but well supported on modern browsers.
  • You used let for all variables. I would recommend using const by default and only using let if the value changes later. Looking at this exercise you could use const for every variable except newStory (because it changes when we replace the placeholders). This helps avoiding mistakes.

I hope that helps,
Michael

Thank you sir, I will fix them.
Your comments are very helpful.
I hope you have a nice day!

1 Like

Great improvements!
Now it looks perfect. :slightly_smiling_face: