Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables The Variable Challenge

NaN value appear in browser instead of desired result, whats wrong in my coding?

/* This is the code I put in story.js sometimes it comes out on browser only "NaN" or NaN + word3 I cant seems to find whats wrong*/

alert("Hello And Welcome To Story Generator 1.0");

alert("This games take 3 input value and then generate random story based on the input");

var word1 = prompt('Insert An Adjective Ex: Brave');

var word2 = prompt('Insert A Verb Ex: Change');

var word3 = prompt('Insert A Noun Ex: world');

var story = 'There was once a ' + word1;

story =+ ' person who wants to ' + word2;

story =+ ' the ' + word3;

document.write(story);

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Mohd,

It should be += not =+. Flip those around and see if that works.

:dizzy:

Thanks, it works !