I know this probably easy #map#foreach

Hi long time no see i was refurbishing my javascript a bit in an old weather app script… as such
and ran into this, and also i use typescript so maybe bit tricky =)
this is the code that is calling the service, and

this._weather.dailyForecast()
	.subscribe(res =>  { 
	let temp_max = Object(res['Time Series (1min)']).map((hello)=>console.log(hello))

and the problem is every map hello is a date per minute so it feed me 100 of those entries
But big but, the hello has now no tail the object it holds disappears and now they are just
100 strings?
i know i maybe do it wrong but please help me with this
thanks!
`

It looks like you are maybe attempting to use a map where you want to use a forEach? map is used to transform the array values, but you are returning a console.log statement.

@donjon It looks like the there are a couple of issues here. Also on a side note, what weather api are you using?

let temp_max = Object(res['Time Series (1min)'])
    .map((hello)=>console.log(hello))
  1. You can used map on an object it has to be on an array, try Object.keys(), or Object.values() instead.
  2. Array.map is used to mutate array items and return them as a copy. In this instance you are returning the result of console.log and not the value of hello. So temp_max is an array of console.log results which probably is not what your looking for.
  3. temp_max would be an array here and not the actual max temp from the time series.

There isn’t a lot of context around your question, but based on what I think you’re trying to accomplish maybe try something like this.

this._weather.dailyForecast()
    .subscribe(res =>  {
        
        // create an array of temperatures
        // I'm not sure what the actual structure of res['Time Series (1min)'] is
        // but in order to use map you must have an array so you can use
        // Object.values().map(), Object.keys().map() or just just plain
        // res['Time Series (1min)'].map() if it's already an array
        let dataSet = Object.values(res['Time Series (1min)'])
            .map((hello) => {
                // dont't return the the rsult of console.log
                console.log(hello); // log temp
                
                return hello; // return temp
            });
        
        // use Math.max to get the max temp from the dataSet
        // alternatively you could use Math.max.apply(Math, dataSet)
        let temp_max = Math.max(...dataSet);
    })
	this._weather.dailyForecast()
	.subscribe(res =>  { 
	
	//.map((hello)=>console.log(hello))
	
		let temp_max 
		 Object.keys(res['Time Series (1min)']).map((d)=> 
		this.era.push(res['Time Series (1min)'][d]['4. close']))
		console.log(this.era)

Yes thanks a bit late but i figured out the object.key stuff thanks for help
ccheers!