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 Solution

Save/Download Logs & Delay Alerts.

1 Is it possible to save & download the log when the page is closed?

In case I want to track the information being entered.

2 Is it possible to delay an alert?

Right now, the Program END alert appears right after the Message READY alert, so that you see the final alert before you see the message on the page. I don't like that.

3 Is it possible to set my Program END alert to appear just before the browser/tab is closed?

Instead of an Are You sure You Want To Leave alert, it is a Thank you, Come Again alert.

alert('Let\'s play a game!');  // Alert Program BEGIN.
console.log('Program BEGIN.');  // Log Program BEGIN.

var adjective = prompt('Please type 1 Adjective.');  // Prompt adjective.
console.log(adjective);  // Log Prompt adjective.

var sentence = '<h2>There was once was a ' + adjective;  // Sentence BEGIN.
console.log('Sentence BEGIN');  // Log Sentence BEGIN.

var verb = prompt('Please type 1 Verb.');  // Prompt verb.
console.log(verb);  // Log Prompt verb.

var noun = prompt('Please type 1 Noun.');  // Prompt noun.
console.log(noun);  // Log Prompt noun.

sentence += ' programmer who wanted to use Javascript to ' + verb;

sentence += ' the ' + noun + '.</h2>';  // Sentence END.
console.log('Sentence END');  // Log Sentence END.
console.log('Message READY');  // Log Alert Message READY.

alert('All done. \ Ready for the message?');  // Alert Message READY.

document.write(sentence);  // Show Message.
console.log(sentence);  // Log Show Message.

alert('Good Job! \ Thanks for playing.');  // Alert Program END.
console.log('Program END.');  // Log Program END.