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

JavaScript Object-Oriented JavaScript (2015) Introduction to Methods Returning Values

Complex and Confused type programming

Hello Treehouse Mates!

I think my code is more easy to understand than Andrew. I'm sorry to say to Andrew, your codes are very hard to understand for a beginner Sir. Here is my Codes

document.getElementById("button").onclick=function(){
  var placeholder=document.getElementById("placeholder");
  var result=Math.floor(Math.random()*6)+1;
  placeholder.innerHTML=result;
}

Hope its help others.

2 Answers

Hi Issac,

Sorry for the delay in returning to your answer request I have been away over Easter.

Unfortunately I have to agree with Steven in this case. There is times when learning with treehouse that you need to look at the code being used as an illustration of what they are trying to explain not a literal example of how you would implement that within a site.

I think if you were to ask the question more on the lines of "why does Andrew not just use this code?" then it would leave us open to explaining the nature of the course and why he is using OOP.

Because the course is about OOP when using JavaScript it would wrong to illustrate the code used in your way.

I hope this helps in some way Craig

Steven Parker
Steven Parker
231,268 Points

I think you're missing the point about using objects and functions for modularity. Your code may do the same thing as the specific example shown, and it is certainly more concise, but it's not as easily maintained or customized.

You mentioned "... for a beginner ..." but this course is rated as "intermediate". Have you already completed all the beginner-rated courses?