title: How to return a nodejs callback as a number, from a JSON object property value?
body: <p>I am trying to do maths on a number within a JSON object (the price of a stock ticker).</p>
  
  <p>I want it to be a variable called 'btcusd_price', that I can then use to do arithmetic with.</p>
  
  <p>How do I get a variable i can work with?</p>
  
  <p><a href="https://tonicdev.com/npm/bitfinex" rel="nofollow">https://tonicdev.com/npm/bitfinex</a></p>
  
  <pre><code>var Bitfinex = require('bitfinex');
  
  var bitfinex = new Bitfinex('your_key', 'your_secret');
  
  var btcusd_price;
  
  btcusd_price = bitfinex.ticker("btcusd", function(err, data) {
    if(err) {
      console.log('Error');
      return;
    }
    console.log(data.last_price);
    return data.last_price;
  });
  
  typeof btcusd_price;
  console.log(btcusd_price); //i'm trying to work with the price, but it seems to be 'undefined'?
  </code></pre>