Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
Javascript List of List only Interpreted within function scope

I am trying to use the node binance api to pull candlestick data for some cryptocurrency data for the last 24 hours. The following is my code;

export function graph(name) {
  return binance.candlesticks(name + "USDT", "1h", function(error, ticks) {
    let points = [];
    for (let i = 1; i <= 25; i++) {
      let last_tick = ticks[ticks.length - 26 + i];
      let [time, open, high, low, close, volume, closeTime, assetVolume, trades, buyBaseVolume, buyAssetVolume, ignored] = last_tick;
      let temp = [time, Number(open), Number(high), Number(low), Number(close)];
      points.push(temp);
    }

    console.log(points) //Prints a list of lists of numbers correctly
    return points

  });
}
console.log(graph("BNB")) // Prints undefined

As commented, when the data is loaded within the function into 'points' using the for loop, I can operate and print it just fine. However, whenever I actually call the function to do something it returns an undefined. When checking typeof, within the function it returns 'object' whereas outside it returns undefined again. Any guidance is appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!