I have completed the silly story generator assessment. Please assess my code and let me know on how I could improve if I have any mistakes. Here is the link to my assessment: https://glitch.com/~scarlet-island-burrito
Hi @Arthur_Chen!
This is working pretty much perfectly, except for one part — the if(document.getElementById("uk").checked) { ... }
block.
When the UK radio button is selected, the temperature and weight are outputted into the story as NaN
(not a number). This is because in each case you are trying to run the Math.round()
function on the whole string, not just the number part of the string. For example:
let weight = Math.round(300 / 14 + ' stone');
If you changed this to
let weight = Math.round(300 / 14) + ' stone';
Then it would work fine.
Also, you’ve got the two variables the wrong way round in these lines:
newStory = newStory.replace('94 fahrenheit', weight);
newStory = newStory.replace('300 pounds', temperature);
But apart from that, it is working well. Great work here, well done!