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.

Amrit Ramos
Courses Plus Student 5,256 PointsWhere can I add the .toLowerCase() code in my code
Hi. I keep wanting to add the .toLowerCase() somewhere into my code. I've tried various places but it does not work. Does someone have any idea as to where I could add it for it to work? Below is my code:
let userScore = (0);
let userRank;
const answer1 = ("blue");
const answer2 = ("green");
const answer3 = ("orange");
const answer4 = ("black");
const answer5 = ("red");
const question1 = prompt("What color is the sky?");
// this the code to give the user its score
if (question1 === answer1) {
userScore +=1;
}
const question2 = prompt("What color are the trees?");
if (question2 === answer2) {
userScore +=1;
}
const question3 = prompt("What color is an orange?");
if (question3 === answer3) {
userScore +=1;
}
const question4 = prompt("What color is a black pen?");
if (question4 === answer4) {
userScore +=1;
}
const question5 = prompt("What color is a strawberry?");
if (question5 === answer5) {
userScore +=1;
}
// this the code to give the user its ranking
if (userScore === 5){
userRank = ("Gold");
} else if (userScore >= 3) {
userRank = ("Silver");
} else if (userScore >=1){
userRank = ("Bronze");
} else {
userRank = ("you did not get a");
}
2 Answers

Anthony Chalabis
1,574 Pointslet userScore = (0);
let userRank;
const answer1 = ("blue");
const answer2 = ("green");
const answer3 = ("orange");
const answer4 = ("black");
const answer5 = ("red");
//Not practical but you can add .toLowerCase to the end of every prompt
const question1 = prompt("What color is the sky?").toLowerCase();
// this the code to give the user its score
if (question1 === answer1) {
userScore +=1;
}
const question2 = prompt("What color are the trees?").toLowerCase();
if (question2 === answer2) {
userScore +=1;
}
const question3 = prompt("What color is an orange?").toLowerCase();
if (question3 === answer3) {
userScore +=1;
}
const question4 = prompt("What color is a black pen?").toLowerCase();
if (question4 === answer4) {
userScore +=1;
}
const question5 = prompt("What color is a strawberry?").toLowerCase();
if (question5 === answer5) {
userScore +=1;
}
// this the code to give the user its ranking
if (userScore === 5){
userRank = ("Gold");
} else if (userScore >= 3) {
userRank = ("Silver");
} else if (userScore >=1){
userRank = ("Bronze");
} else {
userRank = ("you did not get a");
}

Shamique Etienne
Courses Plus Student 1,832 Pointslet userScore = (0);
let userRank;
const answer1 = ("blue");
const answer2 = ("green");
const answer3 = ("orange");
const answer4 = ("black");
const answer5 = ("red");
//Not practical but you can add .toLowerCase to the end of every prompt
const question1 = prompt("What color is the sky?").toLowerCase();
// this the code to give the user its score
if (question1 === answer1) {
userScore +=1;
}
const question2 = prompt("What color are the trees?").toLowerCase();
if (question2 === answer2) {
userScore +=1;
}
const question3 = prompt("What color is an orange?").toLowerCase();
if (question3 === answer3) {
userScore +=1;
}
const question4 = prompt("What color is a black pen?").toLowerCase();
if (question4 === answer4) {
userScore +=1;
}
const question5 = prompt("What color is a strawberry?").toLowerCase();
if (question5 === answer5) {
userScore +=1;
}
// this the code to give the user its ranking
if (userScore === 5){
userRank = ("Gold");
} else if (userScore >= 3) {
userRank = ("Silver");
} else if (userScore >=1){
userRank = ("Bronze");
} else {
userRank = ("you did not get a");
}