More and more api's are allowing developers to call JSON objects which saves a bunch of time. In order to create your object, start by adding the usual script type="text/javascript".
Next, create your variable.
var TravelDistance {
"Dallas" : {
"Houston" : 4,
"New Orleans" : 8,
"Austin" : 6
}
}
After the opening body tag, place another script tag. Print out your results.
document.write(TravelDistance.Dallas.Austin);
The result should end up about 6 hours. Not sure if that's the actual travel time, but that's an example of how to create an object.
No comments:
Post a Comment