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 trialJonathan Ambriz
Courses Plus Student 3,902 PointsRangeError: Maximum call stack size exceeded
Snapshot: https://w.trhou.se/nqjslftqtk
I tried following along the video, but can't get the same output as the instructor. I get the following output:
setter called: [object Object]
/home/treehouse/workspace/Pet.js:39
const phoneNormalized = phone.replace(/[^0-9]/g, '');
^
RangeError: Maximum call stack size exceeded
at String.replace (<anonymous>)
at Owner.set phone as phone
at Owner.set phone as phone
at Owner.set phone as phone
at Owner.set phone as phone
at Owner.set phone as phone
at Owner.set phone as phone
1 Answer
Robert Manolis
Treehouse Guest TeacherI had a similar result. I double checked the video, and in it, Ashley adds underscores just before the phone property in the getter and setter, like so: this._phone. Adding the underscore to those two spots fixed it and the code ran fine.
Michael Kobela
Full Stack JavaScript Techdegree Graduate 19,570 PointsMichael Kobela
Full Stack JavaScript Techdegree Graduate 19,570 PointsApparently the class member needs a different name then the ones used within the setter and getters, otherwise they keep calling themselves and you get the stack size exceeded (stack overflow). I made these changes to your class and it works now: