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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Abson Chifodya](https://secure.gravatar.com/avatar/578c3dbe47921d5db8162e7a2f1111d8?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Abson Chifodya
11,817 PointsInside the getter method use the conditional statement of your choice to determine the level of the student. If the valu
Inside the getter method use the conditional statement of your choice to determine the level of the student. If the value of the "credits" property is over 90, return 'Senior'. If it's between 61 and 90, return 'Junior'. If it's between 31 and 60, return 'Sophomore'. If it's 30 or less, return 'Freshman'.'
class Student {
constructor(gpa, credits){
this.gpa = gpa;
this.credits = credits;
}
get level( ) {
if (this.credits >= 90 ) {
return 'Senior'
}else if ( this.credits >=61 && this.credits<=90){
return 'Junior'}
else if ( this.credits >= 31 && this.credits<= 60){
return 'Sophomore'}
else ( this.credits <= 30){
return 'Freshman' }
}
stringGPA() {
return this.gpa.toString();
}
}
const student = new Student(3.9);
5 Answers
![Julian Cobos](https://uploads.teamtreehouse.com/production/profile-photos/9625802/micro_File_Oct_11__11_16_14_AM.jpg)
Julian Cobos
10,645 PointsI find this website to be very useful for JS. https://www.w3schools.com/jsref/default.asp
class Student {
constructor(gpa, credits){
this.gpa = gpa;
this.credits = credits;
}
stringGPA() {
return this.gpa.toString();
}
get level() {
if (this.credits > 90) {
return "Senior";
} else if (this.credits >= 61) {
return "Junior";
} else if (this.credits >= 31) {
return "Sophomore";
} else {
return "Freshman";
}
}
}
const student = new Student(3.9);
![Martin Lecke](https://secure.gravatar.com/avatar/9cac4eebe6727cdf195eba927d046da2?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Martin Lecke
14,385 Points...
if (this.credits >= 90 ) {
return 'Senior'
}
...
When you write >= You are saying this.credits should be above 90 but it can also be 90. Which is not over 90 which we are looking for in this case.
Also you are not needed to write;
this.credits >=61 && this.credits<=90
There is no need to state a range between numbers since your if-statement will read top to bottom if things are true. Since the higher if statements doesnt turn true it means its not above 90, and its not above 60
get level() {
if(this.credits > 90) { // is my credit above 90? - no
return 'Senior';
} else if(this.credits > 60) { // is my credit above 60 then? - no
return 'Junior';
} else if (this.credits > 30) { // But my credit is above 30? - yes
return 'Sophomore'; // this code runs
} else { // everything less than 30 would have run here, even negative credits
return 'Freshman';
}
}
![Ana-Maria Latiu](https://secure.gravatar.com/avatar/857f803958cc98581b1979f1f1ed1d1b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ana-Maria Latiu
5,709 PointsThanks to all
![Nnanna Okoli](https://uploads.teamtreehouse.com/production/profile-photos/9563892/micro_Screenshot_2022-01-26_at_20.12.46.jpg)
Nnanna Okoli
Front End Web Development Techdegree Graduate 19,181 Pointsget level () {
if (this.credits > 90) {
return 'Senior';
}
else if(this.credits >= 61) {
return 'Junior';
}
else if(this.credits >= 31) {
return 'Sophomore';
}
else {
return'Freshman'
}
}
}
IS YOUR CORRECT ANSWER
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsYou're really close, but I see two issues:
A plain "else" doesn't take (or need) a conditional expression.
Also, the instructions say "If the value of the "credits" property is over 90, return 'Senior'", but this code will also return 'Senior' when the credits are exactly 90.
So just remove the unneeded conditional and change your comparison from ">=" to just ">" and you'll have it.