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.
I have two remarks:
- Instead of using two times
newStory = newStory.replace(':inserta:' , xItem);
you could also usenewStory = 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 usingconst
by default and only usinglet
if the value changes later. Looking at this exercise you could useconst
for every variable exceptnewStory
(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.