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

125
Views
How to get correct Data from Array of arrays

I have following function in react.

const [dataTemperature, setDataTemperature] = useState();

 useEffect(() => {
      let newData = [];
       function lineChart (arg){
          const loop = arg.map((value) => {
              return Math.round(value.main.feels_like - 273.15);
            })
            newData.push(loop);
          };

          let xAxis = newData.sort();
          console.log("xAxis", newData[1])
          let xAxis2 = [...new Set(xAxis)]

            setDataTemperature(newData)
          lineChart(state.fromTemperature.list)
        },[])
         

enter image description here

I am getting some data as a props (state.fromTemperature.list this is array of objects), I map this through this in loop function to get only value and I push this value to newData. I expect this to be simple array where I can use array methods to sort it and remove duplicates. But It didn´t work. I check the type of newData and It show that it is object. I think now it is array of array but I am not sure. In a case it is something like this should work

 let xAxis = newData.map((x)=> x.sort((a, b)=> {return a-b}));

but it doesn´t. Thank you

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!