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.

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Introducing Conditional Statements

Supratim Nandi
Supratim Nandi
3,287 Points

Add a conditional statement

var answer = prompt("What is the Best Programming Language"); if ( answer.toUpperCase() === 'JAVASCRIPT' ) { document.write("You are right"); }

//The code returns null value to if..I dunno y?

Arielle Foldoe
Arielle Foldoe
8,132 Points

I copied and pasted the code you shared into my workspace and the null message didn't pop up. The only things I can reasonably conclude is there might've been some ind of glitch or perhaps nothing getting typed into the box was getting a null response as the problem couldn't have a value within the function?

Arielle Foldoe
Arielle Foldoe
8,132 Points

I copied and pasted the code you shared into my workspace and the null message didn't pop up. The only things I can reasonably conclude is there might've been some ind of glitch or perhaps nothing getting typed into the box was getting a null response as the problem couldn't have a value within the function?

1 Answer

Supratim Nandi
Supratim Nandi
3,287 Points

I printed it with the help of document .write ..it showed answer taken is null.