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
Eugene B
1,305 PointsUsing the ternary operator for the getter method and I get an error.
Error msg: Bummer! Your conditional statement is returning the wrong student level. My code:
get level(){
const credits = this.credit;
return (credits <= 30 ? "Freshman" : credits < 61 ? "Sophomore" : credits <= 90 ? "Junior" : "Senior");
}
I created a separate function and compared the results against the condition: "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'.'
What did I miss?
1 Answer
Steven Parker
243,656 PointsThe ternary is fine, but you're assigning "credits" from "this.credit" (singular) instead of "this.credits" (plural).
Eugene B
1,305 PointsI knew it must be some stupid mistake. Thank you Steven.
Eugene B
1,305 PointsEugene B
1,305 PointsThis is Challenge Task 2 of 2 from Object-Oriented JavaScript.