JSFiddle - React, Tailwind, and code Playground

by Andra Jimenez

JavaScript

//json example

//simplest json - which is an object
// properties define something as an object, so if you can refer to //it as a dot i.e
//JSON do nothing bt define data

// Example of a book object

var aBook = {
    "isbn": "94234-123A",
        "title": "Of Mice and Men",
        "pages": 102,
        "autor": "John Steinbeck",
        "languages": ["english", "french (translate)"],
        "published":2006

};

//json above, but always can add properties later or replace

aBook.genre = "Southern hobo fiction";
aBook.autor = "Andrea Jimenez";

//now we have the book, lets go through and read what's inside it

//Set up a for loop, but instead of saying i=0 as before
//now use ->in<-. to declare variable (in this case key)
//then run, and view in console log

//Quick note -- the ordering is not enforece; don't expect these properties to be in the same order you put them in above

for (var key in aBook){
 console.log("The Key is " + key + " and that value is " + aBook[key]);   
}

//can add one object to another (nesting)