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

Any recommendations for this quick "questionnaire" (apart from the clear lack of legitimate interior design advice)?

alert("Good evening! You're about to endure a very simple test, at the end of which you will be given a loose guide to curtain colours. This guide is by no means intended as a replacement for your own intuition or professional interior design advice.");

var colour = prompt("What's your favourite colour?"); colour = colour.toLowerCase(); var emotion = prompt("The effect of " + colour + " makes me feel _________."); emotion = emotion.toLowerCase(); alert("Congratulations on completing this brief questionnaire! Based on the answers you've given; if, in the room you're redecorating, you wish to feel perpetually " + emotion + ", a JavaScript's recommendation for the curtains base colour choice is " + colour + ". May your curtains serve you well!");

2 Answers

Jeremy Fisk
Jeremy Fisk
7,768 Points

Perhaps you could develop a list of emotions to check if the emotion they enter is in the prompt , otherwise they can input any string they like into the emotion prompt and receive many alert messages that would then, not make any sense at all. this may not be very realistic for the purposes of this exercise, but if you were coding this for an interior design company you might need to consider something like that

I think it's fine for this stage of learning. Perhaps after you've progressed further with JavaScript (which you probably have by now), you could try some of the following:

  • Get the time of day and change the greeting based on that (Good morning/afternoon/evening)
  • Make a colour-picker so the user can see the colours and choose one instead of typing its name
  • Similar to Jeremy Fisk's advice, create a list of emotions to select from (probably better to use HTML to list them)
  • Display a HTML element with the colour that was chosen (you'd need to ensure the colour is a valid CSS colour or can at least be converted into one).