#33 Review is not giving a return value?


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

I am curious why i am not receiving any return when i console.log (objectName.objectMethod())
Is there something i'm not seeing here. i want to see how this function works and so i called the method in my object - and i do not get any return on screen.

I thought that that was the proper way to call a method?

Any light would be greatly appreciated.

function Circle (radius) {
    this.radius = radius;
    this.area = function () {
       return Math.PI * this.radius * this.radius;
    var myObj = new Circle(40)
console.log (myObj.radius)
console.log (myObj.area)


because first you need to create instance of an object:

var a = new Circle(3);

while creating the instant, you pass the radius. then you can call the area method on your new instance (a)


Hi , just caught and re-edited the post - yet still - the console is not logging :

console.log (myObj.radius)
nor -
console.log (myObj.area)


uhm... at this point i assumed you had learned that you should create an instance of the object after the object construction? How can i create an instance of something which hasn't fully being constructed?

methods are functions inside methods, just like normal functions methods require methodname + () to execute. with between the parentheses arguments if they should be supplied


I agree - sorry i've tried so many copies of this - i'm not being accurate,

console.log (myObj.area (40)) - gives no answer
that would be
console.log (objectName.methodName (x value))


line 7 on which you create in instance should be after your object (your object constructor ends at line 9)

you pass the radius when you create the instance, the area method doesn't have any parameters, so it shouldn't have any arguments either


You Really cleared that up for me - I admit i was confused about that part of methods. So because our method doesn't have any parameters there should be no arguments past either.

I'm going to be more careful about my brackets and Syntax , Review methods verse functions with Objects --- and slooow it down and pay more attention. Many thanks!!


no, just like with methods (just like normal functions) the number of parameters should match the number of arguments.

Okay, issue resolved? Keep coding, then it will get better


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