Good evening!
Can someone tell me how I can return the object using an invocation of type:
book (book1);
function book(bookName) {
var obj = {
livro1: {
quantidadePaginas: 300,
autor: "Jorge",
editora: "Atlas"
},
livro2: {
quantidadePaginas: 200,
autor: "Paulo",
editora: "Cia dos Livros"
},
livro3: {
quantidadePaginas: 150,
autor: "Pedro",
editora: "Bartolomeu"
}
};
if (!bookName) {
return obj;
};
return obj.bookName;
};
When I try to return this way, it appears that book1 is not set.
Where is my thinking wrong?
What do I need to change in the function so that I can return the value of the x (librox) object using the book (book) invocation?