[Solved] Stuck with the creation of a book object for the_hobbit


#1

https://www.codecademy.com/fr/courses/javascript-beginner-fr-FR/5/3?curriculum_id=5355c2b7516bcbd912000008#


function Livre(pages, auteur) {
    this.pages = pages;
    this.auteur = auteur;
}
var le_hobbit = new Livre(320,"J.R.R. Tolkien");

Oups, merci de réessayer. Avez-vous crée le nouveau avec l'objet Livre ?


#2

Désolé, je ne suis pas couramment la langue française , mais déménagement

avant :


#3

Hi bayoishola20,
I don't think so because the declaration of the constructor must be before the creation of the object itself. Beside this, I follow the file format of this exercice. I try anyway but it doesn't change anything.
I really don't know what is wrong with this declaration.

arnome.


#4

Okay, the exercise says to do it in three lines. So, you should do something like this:

var harry_potter = new Object();
harry_potter.pages = 350;
harry_potter.auteur = "J.K. Rowling";

#5

This exercise says that we have to use the constructor in one line, beside this I try

var le_hobbit = new Object();
le_hobbit.pages = 320;
le_hobbit.auteur = "J.R.R. Tolkien";

but it's not working too. I really don't how to get throw this. Thank you for taking time with my problem, bayoishola20.

arnome.


#6

It's 350 not 320. :slight_smile:


#7

No, no it's really 320: :wink:

Pour cet exemple, nous voulons que notre livre ait 320 pages, et que l'auteur soit "J.R.R. Tolkien".
trad:
In this sample, we would like to have a book of 320 pages and the author be "J.R.R. Tolkien".

I really write the right solution, I think...

arnome.


#8

Oooo... My bad! It's 320 really. :mask:


#9

The full stuff now:

var le_hobbit = new Livre();
harry_potter.pages = 320;
harry_potter.auteur = "J.R.R. Tolkien";

function Livre(pages, auteur) {
    this.pages = pages;
    this.auteur = auteur;
}

#10

I pass throw the corrector :sunny:
I make a copy-paste from the tip and it's working fine. The right solution is:

var le_hobbit = new Livre(320, "J.R.R. Tolkien");

very close to mine...
Thank you bayoishola20.
arnome.


#11

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