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 trialKyle Gibbons
1,388 PointsI'm wondering why the attached code is 1, and not true. I ran it through repl.it, and thought I would get true, reason?
var x = 2;
x || true
2 Answers
Shawn O'Connor
14,135 PointsAny non zero number will typically return as 'True'
Cindy Lea
Courses Plus Student 6,497 PointsIm going to say its beause x is not a zero or one which reflects the boolean value of false or true. 2 isnt a boolean value
Kyle Gibbons
1,388 PointsHey Cindy,
Thank you, I believe that might be why. I actually meant 2 in my question, when I changed x = 0, it came back true.
Simon Coates
28,694 PointsSimon Coates
28,694 Pointsi ran it in browsers console and got 2.