11. Class is in Session


#1

function Person(name,age) {
this.name = name;
this.age = age;

}

// Let's make bob again, using our constructor
var bob = new Person("Bob Smith", 30);
var susan = new Person("Susan Jordan", 35);

// make your own class here
var Circle = {
this.radius = radius
}

I don't understand how it should be done.


#2

You don't jave a parameter in your argument. And the keyword "var" is for variables, not classes.

look at the following:

function Circle(radius){
    this.radius = radius;
}

#3

Hi celia1, you made some little mistake over here. Try code like this.

  1. Remove the first equal-to sign (=) after "var Circle".
  2. It's a class so use "Function" as a key word not "var".
  3. Last add a Parameter / Argument to it (radius).

That's it. than create a Object and call it.

after this your code should be seen like this.

function Circle(radius) {
      this.radius = radius;
}

var radius = new Circle(5);

(P.S. you can add any number instead of 5).

Hope this works for you.

Thank You.


#4

var Circle = function(radius){
this.radius= radius;
};


#6

function Person(name,age) {
this.name = name;
this.age = age;
}

// Let’s make bob again, using our constructor
var bob = new Person(“Bob Smith”, 30);
var susan = new Person(“Susan Jordan”, 35);

// make your own class here
function Circle(radius){
this.radius=radius;}
var radius=new Circle(90)

hi ,i never understand what means it
this.radius=radius
what happened for this ?
thanks