Silly story generator(assessment)

hey @chrisdavidmills just finished the first JS module assessment, I think I did just fine, i just have a question .The assessment page steps to complete says we should put the <script> tag just before the closing </body> tag, of course! I didn’t need this cause I used codepen but I just wanna know if using the defer attribute in the <script> tag before the <body> tag would be better in this kinda task.

Hello @owolagbadavid

hope that everything going fine with you

putting the script at the end of the body make sure that the script run after the page load same thing as if you used defer

you use defer when you have external script file
if you used defer with internal script it will not work and give you error
try make use defer with internal script and validate it https://validator.w3.org/

hope that help and have a nice day

by the way this line
newStory = newStory.replace(’:insertx:’, xItem);

only replace the first :insertx: not the second you can use replaceAll instead

thanks to @aviv.mu @chrisdavidmills for the replace explaining Why this is not working

hope that help and have a nice day

@justsomeone
Oh yeah!!
Didn’t see that, thanks

you welcome :slight_smile:

it’s recommended to put your script in external file/files which will lead to the use of defer if you want it and also use external file/files for the css

hope that help :slight_smile:

have a nice day

you welcome :slight_smile: