Using JS Objects + Datasets 1

by Cory Hughes

HTML

<h1><span id="currency"></span> Rate:</h1>
<div><span id="rate"></span></div>

JavaScript

var obj = [{
  "disclaimer": "This data is collected from various providers and provided free of charge for informational purposes only, with no guarantee whatsoever of accuracy, validity, availability, or fitness for any purpose; use at your own risk. Other than that, have fun! More info: http://openexchangerates.org/terms/",
  "license": "Data collected from various providers with public-facing APIs; copyright may apply; not for resale; no warranties given. Full license info: http://openexchangerates.org/license/",
  "timestamp": 1339036116,
  "base": "USD",
  "rates": {
    "EUR": 0.795767,
    "GBP": 0.645895,
    "JPY": 79.324997,
    "USD": 1
  }
}];

rate.innerHTML = (obj[0].rates.GBP);
currency.innerHTML = Object.keys(obj)[0];