23/33 more options PLEASE HELP BRAIN HURTS


#1

it says syntax error please help me...............

function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}

var sally = new Object()
var holden =new Object()
function Person(name,age) {
this.name = Sally Bowles;
this.age = 39;
}
var holden =new Object()
this.name = Holden Claufield;
this.age = 16;
}
console.log("sally's species is " + sally.species + " and she is " + );
console.log("holden's species is " + holden.species + " and he is " + );


#2

thanks for helping me in advance


#3

Hey @javaace35682,

You did it in a much complicated way than you should have. :smiley:

Take out all of this:


I'm showing you the way I did. :blush:

You don't exactly have to do it my way, but just telling you.

Now, you can call sally and and holden as a new Person, not Object, using the Person function.

var sally = new Person(name, age)

That's an example. :smiley:


#4

The problem is when you created your people. You made them an object when they should be a Person type, this is why you made a constructor for Person. What you do to make them with the person constructor is:

var sally = new Person("Sally Bowles", 39);

The correct code:

function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}
var sally = new Person("Sally Bowles", 39); 
var holden = new Person("Holden Claufield", 16)
console.log("sally's species is " + sally.species + " and she is " + );
console.log("holden's species is " + holden.species + " and he is " + );

#5

Still won't work but thanks for replying


#6

var sally = new Person("Sally Bowles", 39);
var holden = new Person("Holden Claufield", 16)
console.log("sally's species is " + sally.species + " and she is " + sally.age);
console.log("holden's species is " + holden.species + " and he is " + holden.age);


#7

missed your answer but I got the lucky guess and it worked :).


#8

this is the correct code:-

function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}

var sally = new Person("Sally Bowles", 39);
var holden = new Person("Holden Caulfield", 16)
console.log("sally's species is " + sally.species + " and she is " + sally.age);
console.log("holden's species is " + holden.species + " and he is " + holden.age);


#9

I wrote the correct code but it says unspecified error. What do I do?
function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}
var sally = new Person("Sally Bowles", 39);
var holden = new Person("Holden Caulfield", 16)
console.log("sally's species is " + sally.species + " and she is " + sally.age);
console.log("holden's species is " + holden.species + " and he is " + holden.age);


#10

you forgot the semicolon after var holden = new Person("Holden Caulfield", 16), it should be var holden = new Person("Holden Caulfield", 16);
hope this helps.


#11

my code:

function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}
var sally = new Person("Sally Bowles", 39);
var holden = new Person("Holden Claufield", 16);

console.log("sally's species is " + sally.species + " and she is " + );
console.log("holden's species is " + holden.species + " and he is " + );

it's says: Oops, there was a problem with your syntax.
unexpected token )


#12

Hey riesmagi I had the same problem until i reread the task.

You forgot "Edit the sentence printed out such that it includes the age of sally and holden respectively."

the code you have now :
console.log("sally's species is " + sally.species + " and she is " + );
And should be like this
console.log("sally's species is " + sally.species + " and she is " + sally.age );
Or just remove the +

Hope this helps.


#13

function Person(name,age) {
this.name = name;
this.age = age;
this.species = ("Homo Sapiens");
}

var sally = new Person {
this.name = ("Sally Bowles");
this.age = 39;
};
var holden = new Person {
this.name = ("Holden Caulfield");
this.age = 16;
};
console.log("sally's species is " + sally.species + " and she is " + sally.age);
console.log("holden's species is " + holden.species + " and he is " + holden.age);

Oops, try again. There was a problem with your syntax.
SyntaxError: Unexpected token {

please help me


#14

unction Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}

var sally = new Person("Sally Bowles", 39);
var holden = new Person("Holden Claufield", 16)

console.log("sally's species is " + sally.species + " and she is " + sally.age);
console.log("holden's species is " + holden.species + " and he is " + holden.age);

Oops, try again. Make sure holden has the name 'Holden Caulfield'

sally's species is Homo Sapiens and she is 39
holden's species is Homo Sapiens and he is 16


#15

Hi you wrote Holden Claufield instead of Holden Caulfield


#16

CORRET COD IS:

function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}
var sally = new Person("Sally Bowles", 39);
var holden = new Person('Holden Caulfield', 16);

console.log("sally's species is " + sally.species + " and she is " + sally.age );
console.log("holden's species is " + holden.species + " and he is " + holden.age );


#17

You can define global variable which can be inherited by all objects. I am not sure this can solve your query but it can help to solve complexity for huge lines of code. I choose 1z0-808 java SE 8 version to control this.


#18

Hope this can help someone.

function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}

var sally = new Person('Sally Bowles',39);
var holden = new Person('Holden Caulfield',16);
console.log("sally's species is " + sally.species + " and she is " + sally.age); // You need add sally's age
console.log("holden's species is " + holden.species + " and he is " + holden.age);// Holden's age