Methods


#1


I'm pretty sure I put everything in properly. error message is unexpected end of input. Where am I going wrong

function Circle (radius){
      this.radius = radius;
      this.area = function(){
          return Math.PI * radius * redius;
      };
      this.perimeter = function(){
          return 2* Math.PI * radius;
      };
};


#2

Are you sure that is suppose to say redius?


#3

wow thank you for that. but it still doesn't pass


#4

Could I see a link to the exercise?


#5

https://www.codecademy.com/courses/spencer-sandbox/5/4?curriculum_id=506324b3a7dffd00020bf661#


#6

Instead of saying radius then you need to say this.radius because your referring to the argument of a function inside the same function. I should have remembered this from the start without needing a link to help me out :slight_smile:


#7

I'm sorry but I made the changes you suggested and it's still not working! Please help me!!!


#8

function Circle (radius) {
this.radius = radius;
this.area = function () {
return Math.PI * this.radius * this.radius;

};
// define a perimeter method here

function Circle (radius){
this.radius = radius;
this.area = function(){
return Math.PI * radius *radius;
};
this.perimeter = function(){
return 2* Math.PI * this.radius;
};
};


#9

You should probably mention what you mean by "not working" otherwise it's difficult to tell what you want it to do differently!


#10

it's giving me the error message unexpected end of input


#11

That means it reached end of file while other code was still expected. When might that happen?

For example, if you write the keyword function, then you're expected to follow that up with a name, or an argument list. If you were to have a file like this:

function

Then it would reach the end of file while expecting something more.
There are a whole bunch of other such scenarios, you'll just have to find which one you've left hanging.


#12

omg I have changed this thing so many times!!! It's telling me I'm returning NaN. Please!!!! I need to move past this!!!

function Circle (radius) {
this.radius = radius;
this.area = function () {
return Math.PI * this.radius * this.radius;
}
};
// define a perimeter method here
function Circle (perimeter){
this.perimeter = perimeter;
this.perimeter = function(){
return Math.PI * this.perimeter * this.perimeter;
}
};


#13

Reproduce that behaviour/confirm that it is indeed happening, and then investigate how it reaches that result.

If you're running into problems then it sounds like you don't need to move on, as there are already things to learn right where you are. The idea is to learn, not to move through exercises, that's merely the means to the end.

If you want to do something else then you can always just skip it.


#14

this.perimeter = function(){
return 2 * Math.PI * this.radius;
}

this worked for me


#15

I figured it out but thank you so very much I appreciate it!


#16

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.