JS Array Help
- Started
- Last post
- 5 Responses
- ETM
I am working with an existing script that pulls stock prices from Yahoo! Finance. I have a question about arrays though. Right now it's using an array to display the 3 prices and using the 'Name' value from Yahoo. But the data they provide is messy. In an array how can I include manual values?
So name in the first set is set as 'A', second set is 'B', third set is 'C '?
Thanks
- mekk0
so you want {Name} to return a manual value depending on what yahoo returns?
- Stugoo0
sorry do you mean like chaining the name like :
query .results .quote[i] .BidRealtime
to get the BidRealtime value?
or do you mean like adding a custom class or data attribute to each output, so that you can target it later?If it is the latter, I would store the result in an array on the DOM so that you can use it later. Or use a name that does something like
var UID = query .results .quote[i] .Name .split(' ') .join();Does that make sense?
- ETM0
@mekk
Not even dynamic depending on what Yahoo returns. The data is always the 3 same values being pulled.So in order I know the first results are WTI Crude Oil, second is Brent Crude Oil and the Third is always Natural Gas.
So I just want to use the titles I want (static) rather than the one that comes from Yahoo 'Name' (which is messy). Just seems more logical to sort it this way than call the script 3 separate times.
- ETM0
Lol. I'm just over complicating it. I'll just stick static titles in the page and format the pricing output to line up with them.
- mekk0
sometimes you see the solution just by writing the problem down :)