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

Here's my interpretation of the variable challenge. Take a look!

alert ("Want to play a game? Follow the instructions")
let introduction = "Remember, remember the 5th of ";
let nouns = prompt ("Give me: 'November'");
let gunpowderString = ", the gunpowder treason and ";
let verbs = prompt ("Please, give me some 'plot'");
let iKnowString = ". I know of no reason why the gunpowder ";
let adjectives = prompt ("Let's write a 'treason'!");
let endString = " shoud ever be forgot.";
alert("Are you ready for awesome story? #V like Vendetta");
let story = introduction + nouns + gunpowderString + verbs + iKnowString + adjectives + endString + " #the end".toUpperCase();
document.write (story);

2 Answers

Dear Konrad S,

You're good with the solution you've come up with. But instead of let, you should use const. When the value of the variable is not to change, then const should be your choice. In fact, you should first consider using const but when you see that the value needs to change, use let.

alert(`Want to play a game? Follow the instructions`)
const nouns = prompt (`Give me: 'November'`);
const verbs = prompt (`Please, give me some 'plot'`);
const adjectives = prompt (`Let's write a 'treason'!`);
alert(`Are you ready for awesome story? #V like Vendetta`);

const story = `Remember, remember the 5th of ${nouns}, the gunpowder treason and ${verbs}. I know of no reason why the gunpowder ${adjectives}  shoud ever be forgot. ${"#the end".toUpperCase()}`;
console.log(story);

And it's always a good idea to move all the variables to the top of the document.
By, the way, I've used string interpolation to get rid of concatenation and unnecessary variables.

Happy Coding !!! :sparkles:

Nafis Fuad

Thank you, for some advice. I like your solution. I will definitely try to use it in practice. ? ?

You're welcome. Happy Learning :smile: