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 trialPablo Calvo
13,044 PointsdrawSVGSpace() requesting X and Y's lenght
All code seems to be equal to the teacher's and workaing however I get this SVG error about the circle lenght x 42times... (I guess is giving an error everytime it tries to create a space)
"Error: <circle> attribute cx: Expected length, "NaN"."
This is my Space.js:
class Space {
constructor(x, y){
this.x = x;
this.y = y;
this.id = space-${x}-${y}
;
this.token = null;
this.diameter = 76;
this.radius = this.diameter/2;
}
drawSVGSpace(){
const svgSpace = document.createElementNS("http://www.w3.org/2000/svg", "circle");
svgSpace.setAttributeNS(null, "id", this.id);
svgSpace.setAttributeNS(null, "cx", (this.x * this.diameter) + this.radius);
svgSpace.setAttributeNS(null, "cy", (this.y * this.diameter) + this.radius);
svgSpace.setAttributeNS(null, "r", this.radius - 8);
svgSpace.setAttributeNS(null, "fill", "black");
svgSpace.setAttributeNS(null, "stroke", "none");
document.getElementById("mask").appendChild(svgSpace);
} }