Giter Site home page Giter Site logo

hyf-javascript2's People

Contributors

sob7i avatar

Watchers

 avatar

hyf-javascript2's Issues

Correct key not being used to retrieve data!

In this function, you are not using the correct keys ('title', 'language' and 'author'). Capitalising the first letter of the key changes the key because JavaScript is case-sensitive. Hence, when you try to retrieve the title of the book on line 184 using boTi.innerHTML = bookDet[bookId].Title; it would not work. The correct way to write this would be boTi.innerHTML = bookDet[bookId].title;

function bookTit(){
let booksInfo = document.createElement("ul");
document.body.appendChild(booksInfo);
for (let bookId in bookDet ) {
let bookT2 = document.createElement("li");
bookT2.setAttribute("id",bookId);
booksInfo.appendChild(bookT2);
let boTi = document.createElement("h2");
bookT2.appendChild(boTi);
boTi.innerHTML = bookDet[bookId].Title ;
let boLa = document.createElement("p");
bookT2.appendChild(boLa);
boLa.innerHTML = bookDet[bookId].Language;
let boAu = document.createElement("p");
bookT2.appendChild(boAu);
boAu.innerHTML = bookDet[bookId].Author;
};
}

Two functions with the same name!

You have made two functions with the exact same name 'bookTit()'. Due to this, the second function is called when you try to call the first function. Also, the second function never runs because the object 'bookDet' is defined after the function is being called for the first time.

function bookTit() {
let bookT1 = document.createElement("ul");
for (i = 0; i < bookTitles.length; i++) {
let bookT2 = document.createElement("li");
bookT1.appendChild(bookT2);
bookT2.innerHTML = booksTitels[i];
}
}
console.log(bookTit());

Keys are in double-quotes!

The keys in the function are in double quotes and due to this, the function 'bookTit()' is never able to retrieve any data.

let bookDet = {
"Zuleika_ Dobson": {
"title": "Zuleika_ Dobson",
"language": "English",
"author": "Max_Beerbohm"
},
" The_Good_Soldier": {
"title": " The_Good_Soldier",
"language": "English",
"author": "Madox_Ford "
},
"The_Thirty_Nine_Steps": {
"title": "The_Thirty_Nine_Steps",
"language": "English",
"author": " John_Buchan"
},
"The_Rainbow": {
"title": "The_Rainbow",
"language": "English",
"author": "DH_Lawrence "
},
"of_Human_Bondage": {
"title": "of_Human_Bondage",
"language": "English",
"author": "W_Somerset_Maugham "
},
"The_Age_of_Innocence": {
"title": "The_Age_of_Innocence",
"language": "English",
"author": "Edith_Wharton"
},
"Ulysses": {
"title": "Ulysses",
"language": "English",
"author": " James_Joyce"
},
" Babbitt": {
"title": " Babbitt",
"language": "English",
"author": "Sinclair_Lewis "
},
" A_Passage_to_India": {
"title": " A_Passage_to_India",
"language": "English",
"author": "EM_Forster"
},
"Gentlemen_Prefer_Blondes": {
"title": "Gentlemen_Prefer_Blondes",
"language": "English",
"author": "Anita_Loos"
}
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.