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) 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.