Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem in Assessment: Silly Story Generator

19 views
Skip to first unread message

Eikansh Gupta

unread,
Sep 26, 2016, 11:43:49 AM9/26/16
to dev...@lists.mozilla.org
Hi,

I am having problem running Silly Story
Generator(https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Silly_story_generator#Starting_point).
I always get error "[object HTMLParagraphElement]". I have even tried
to match my js code with correct code but nothing is working out.
Link to code http://ideone.com/FxNExJ

Thanks in advance.

Chris Mills

unread,
Sep 26, 2016, 12:33:24 PM9/26/16
to Eikansh Gupta, dev...@lists.mozilla.org
Hi there!

I tested your code, and it was exactly right except for one tiny mistake; the related instruction in the assessment text is as follows:

"Finally, in the second-to-last line of the function, make the textContent property of the story variable (which references the paragraph) equal to newStory.”

In your code, you had

story.textContent = story

Which is setting the textContent of the paragraph to be equal to itself, hence it coming up with an [object HTMLParagraphElement] reference - it is an object, not some text.

To fix it, I changed the line to

story.textContent = newStory

which sets the textContent equal to the newStory text string, containing our modified silly story.

Best regards,

Chris Mills
Senior tech writer || Mozilla
developer.mozilla.org || MDN
cmi...@mozilla.com || @chrisdavidmills
> _______________________________________________
> dev-mdc mailing list
> dev...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-mdc
> MDN contributor guide: http://bit.ly/ContributorGuide

Chris Mills

unread,
Sep 26, 2016, 12:34:02 PM9/26/16
to Eikansh Gupta, dev...@lists.mozilla.org
0 new messages