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 trialRoald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,544 Pointsconditional statement not returning correct student level but why? This should work.
Hey everyone,
I'm pretty sure that my conditional statement isn't wrong. Instead of going from high number to low I flipped it since it's running one line of code at a time anyway. Just so I don't need to check the in-between numbers when starting at 90. I had the idea that was a better way of doing it.
Sometimes treehouse challenges are just plainly not recognizing a different way of doing the right thing. I wonder if this is yet another one of those cases.
class Student {
constructor(gpa, credits){
this.gpa = gpa;
this.credits = credits;
}
get level() {
let creds = this.credits;
if (creds <= 30) {
return "they are a 'Freshman'.";
} else if (creds <= 60) {
return "they are a 'Sophmore'.";
} else if (creds <= 90) {
return "they are a 'Junior'.";
} else if (creds > 90) {
return "they are a 'Senior'.";
}
}
stringGPA() {
return this.gpa.toString();
}
}
const student = new Student(3.9);
3 Answers
KRIS NIKOLAISEN
54,971 PointsIn addition to correcting the spelling of Sophomore you should just return the level. This is the value in single quotes. For example:
return 'Freshman';
instead of
return "they are a 'Freshman'.";
Juan Lopez
Treehouse Project ReviewerRoald Jurrian Kamman It works however it seems as though you misspelled Sophomore
which is why it is not working when you try and submit.
Roald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,544 PointsAh, yes. Sophomore was spelled wrong. I caught that one and it still didn't work. Apparently I was too exact in following instructions.