I’m new to JavaScript.
I’m learning Dom and OOP recently. I’m working on a Snake game project now.
I’m trying to use Food.init to create a cube (width: 20px, height:20px) inside .map, But when I use “style.width=this.width+“px”;” to set width, it’s not working!
Please give me some advice about how to solve it.
here is my code:
Thank you so much!
I’m sorry about my expression, I will try to correct.
Your answer is very helpful! The problem is “when this.width is already 20px, if I put this.width + “px”, it will become unnable to set width”.