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 trialDavid Shulkin
Front End Web Development Techdegree Student 10,255 PointsIf anyone is curious about how Case Sensitivity works for one of the examples...
I’ve tried figuring out how to use the .toUpperCase method for case sensitivity when a user is typing in the prompt. The only solution I have found is to remove secretWord variable, pass the 'guess' variable into the 'correct' variable appending .toUpperCase() - this makes it so that when a user is typing in the prompt, it automatically converts their typed answer into all uppercase to match the if statement - where the ‘correct’ variable must be strictly equal to TOMATO.
let message = 'Access denied :(';
for ( let i = 5; i >= 1; i-- ) {
let guess = prompt(`Enter the secret word. You have ${i} tries.`);
let correct = guess.toUpperCase();
if ( correct === 'TOMATO' ) {
message = 'Welcome to the secret loop world!';
break; // immediately terminate the loop
}
}
Note: the text in let = guess prompt(...) are in between two backtick characters for interpolation syntax.
Mod Note - Added markdown to show JavaScript syntax highlighting