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 trialYohan Aton
1,738 PointsNot sure why this isn't working and showing 'Welcome student' in alert message...
var isAdmin = false; var isStudent = true;
if ( isAdmin = true ) { alert('Welcome administrator'); } else if (isStudent = true) { alert('Welcome student'); }
any help or insight would be greatly appreciated. Thanks!
4 Answers
rdaniels
27,258 PointsThis code passed in Chrome...
var isAdmin = false;
var isStudent = true;
if ( isAdmin ) {
alert('Welcome administrator');
}else if (isStudent) {
alert("Welcome student");
}
Hope this helped!
Yohan Aton
1,738 PointsThanks for chiming in!!!
Faraz Hasan
4,596 Pointsalso you can write your code with the black background if you write 3 backticks (```) surrounding it!! I just learnt that the other day....click Markdown Cheatsheet below the answer box to check other syntax examples!!
e.g (without space between backticks - btw backticks on my mac are next to the shift key on the left of the keyboard on same key as ~):
'' ' CODE GOES HERE '' '
Mike West
9,163 PointsJon-
I just ran it in the Chrome console and it worked and provided the correct alert. Are you using Firefox or a different browser? I was using Firefox when I first started and I often wouldn't get alerts. I've switched over to Chrome for all dev work and have no longer had that issue.
Yohan Aton
1,738 PointsHi Mike - Think I'm going to follow your suggestion. Thank You!!!!
mkmk
15,897 PointsUse 2 equal signs == for comparisons and one equals = for assignments.
Yohan Aton
1,738 PointsYup... somehow missed that... Thank You!!!
Yohan Aton
1,738 PointsYohan Aton
1,738 PointsThanks so much - Got it now!