Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
how to would i add user input and still run this code?
gill is console logging it and assigning a variable but what if i want the user to input the information
Cameron ChildresTreehouse Moderator 11,715 Points
A simple way to do this would be using
prompt(), much like in the previous video:
const weather = prompt('What is the weather?');
With the code as written in the video the only acceptable answers will be 'sun', 'rain', or 'snow'. Otherwise the code will run the final
If you want to view the response outside the console you could replace
Thank you but how would we write the if else or it would be written still the same?