poppyc poppyc - 7 months ago 31
Javascript Question

Create new array from elements of 2 http requests

I have 2 json arrays which are the results of 2 http.get requests.
One contains a watch list like:

json1= [

The second one contains stock pricing info:

json2 = [
{“symbol”:”PG”,”name”:”Procter & Gamble Company (The) “,”lastTradeDate”:null,”lastTradePriceOnly”:88.4,”change”:0.35,”dividendYield”:3.04,”peRatio”:23.93,”volume”:1333524},
{“symbol”:”T”,”name”:”AT&T Inc.”,”lastTradeDate”:null,”lastTradePriceOnly”:39.94,”change”:-0.26,”dividendYield”:4.78,”peRatio”:17.22,”volume”:2865061},
{“symbol”:”WM”,”name”:”Waste Management, Inc. Common S”,”lastTradeDate”:null,”lastTradePriceOnly”:62.98,”change”:0.17,”dividendYield”:2.61,”peRatio”:24.61,”volume”:276554}

I wish to create a third json array or object comprised of the first array and all elements of second array where "ticker"(json1) == "symbol"(json2).
This would allow me to utilize ngFor on the new array and get all the required info into one list or table. Any help would be greatly appreciated.


You can do it like this, easy way:

var json3 = [];

        if(b.symbol == v.ticker)