Hi, Paul-Ben
Congratulations, you passed the test.
Okay Paul, this is from me:
- you can use
replaceAll()
method for xItem
, and you can place method directly after another method (it’s you prefer).
newStory = newStory.replace(":insertx:", xItem);
newStory = newStory.replace(":insertx:", xItem);
newStory = newStory.replace(":inserty:", yItem);
newStory = newStory.replace(":insertz:", zItem);
like this:
newStory = newStory
.replaceAll(':insertx:', xItem)
.replace(':inserty:', yItem)
.replace(':insertz:', zItem);
- Take advantage template literal
if(document.getElementById("uk").checked) {
const weight = Math.round(300);
const temperature = Math.round(94);
const stoneWeight = Math.floor(Math.round(weight/14));
const celciusTemp = Math.floor(Math.round((5/9)*(temperature-32)))
newStory = newStory.replace('94', celciusTemp);
newStory = newStory.replace('fahrenheit', 'centigrade');
newStory = newStory.replace('300', stoneWeight);
newStory = newStory.replace('pounds', 'stone');
}
if (document.getElementById('uk').checked) {
const weight = `${Math.round(300 / 14)} stone`;
const temperature = `${Math.round(((94 - 32) * 5) / 9)} centigrade`;
newStory = newStory
.replace('94 fahrenheit', temperature)
.replace('300 pounds', weight);
}