Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created March 26, 2021 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/fccb8aa4d253a1247fd34ed915916d12 to your computer and use it in GitHub Desktop.
Save ssaurel/fccb8aa4d253a1247fd34ed915916d12 to your computer and use it in GitHub Desktop.
Parse JSON for Bitcoin Price in Words
function parseJson(json) {
var time = "on " + json["time"]["updated"];
var usdValue = json["bpi"]["USD"]["rate"];
var gbpValue = json["bpi"]["GBP"]["rate"]; // ToDo later
var euroValue = json["bpi"]["EUR"]["rate"]; // ToDo later
var usdValueInWords = (numberToWords(usdValue.split(".")[0].replace(",","")) + " dollars").toUpperCase();
document.getElementById("content").innerHTML = usdValueInWords;
textToSpeech = "Bitcoin price is " + usdValueInWords;
// we call back in 60 seconds
setTimeout(bitcoinPrice, 60000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment