I need Help on the guessing game. followed all the steps but it’s not responding as expected.
Thanks
I need Help on the guessing game. followed all the steps but it’s not responding as expected.
Thanks
There is somthing strange with this codepen,
try changing this:
<body>
<div>
to:
<body>
<div>
Done! changes effected as suggested
@Rafael_Green
when i checked his link was thinking why it behave like that
well done man
have a nice day both of you @Rafael_Green @jerevick83
In other words your’re saying it works fine?
The code can,t actually generate the random stories, it can’d replace the placeholders in the ‘newStory’ string, and can.t replace the name ‘Bob’ with the ‘customName’
we are not saying that but @Rafael_Green target the issue that make your result show the html code let me dive into it and tell you the issue
replace the following line
newStory.replace(’:insertx:’,xItem); to newStory=newStory.replace(’:insertx:’,xItem);
do the same for the other lines
why ? cause string is immutable so its does not change it’s value so you need to assign the return value of replace to the newstory variable again
another little thing
let storyText = (‘It was 94 fahrenheit outside, so :insertx: went for a walk. When they got to :inserty:, they stared in horror for a few moments, then :insertz:. Bob saw the whole thing, but was not surprised — :insertx: weighs 300 pounds, and it was a hot day.’);
you do not need the () thing just the quote
you doing great and by the way i fall for the same string immutable issue before
well done and have a nice day
ops i forget use newStory = newStory.replaceAll(’:insertx:’,xItem); with insertx cause it exist twice cause replace only replace the first occurrence
Thanks a lot.
However, JS is saying that ‘replaceAll’ is not a function.
I have figured it out with regex newStory.replace(/:insertx:/g, xitem);
It works perfectly now
Thanks. Again
check this
well done with the regex
you very welcome
It was a browser compatibility issue.
I launched it on chrome which does not support it as of now.
Knowledge gained
thanks for that info i forget to check the compatibility table
well done and thanks gain