'Math.max.apply method and spread (...) function returning Infinity/NaN when processing an array
I am using the Math.max function to process an array using the spread function, but am still receiving a NaN error. Any help into this matter would be greatly appreciated.
import finnhub from 'https://cdn.skypack.dev/finnhub';
const api_key = finnhub.ApiClient.instance.authentications['api_key'];
api_key.apiKey = "c5cam0iad3ib55bb0ajg"
const finnhubClient = new finnhub.DefaultApi()
let stockTicker = prompt("Please enter the symbol of the stock to chart:");
//Finance API Function Call Below
finnhubClient.stockCandles(stockTicker, "D", ((Math.trunc(Date.now() / 1000)) - 8640000), Date.now(), (error, data, response) => {
let dataSetDayHigh = []
let dataSetDayRange = 1
for (dataSetDayRange = 1; dataSetDayRange < 41; dataSetDayRange = dataSetDayRange + 1){
dataSetDayHigh[dataSetDayRange] = Math.trunc(data.h[dataSetDayRange])
}
let yAxisRangeUpper = Math.max.apply(null, dataSetDayHigh)
console.log("Data Set Day High Values = " + yAxisRangeUpper)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
