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

140
Views
How to solve this time- series transformation challenge code

The detailed code is here: https://jsfiddle.net/prettyboy811/v0L3kg5d/2/

This is the first time that I have seen this data transformation. Please help me with this. Thanks!

The question provides series of test. We need to add the code in order to pass the tests:

describe('when receiving data for multiple points in time', () => { 
    it('returns the expected output', () => {
      const input = [
        { data: [[1242362340000, 10], [1242362340001, 4]] },
        { data: [[1242362340000, 6], [1242362340001, 9]] },
        { data: [[1242362340000, 11], [1242362340001, 13]] },
      ];
      const output = {
        1242362340000: {
          x: 1242362340000,
          points: [10, 6, 11],
          total: 27,
        },
        1242362340001: {
            x: 1242362340001,
          points: [4, 9, 13],
          total: 26,
        }
      };
            responseToTimeseries(input).should.deep.equal(output);
    });
  });
  
  describe('when some point is missing', () => { 
    it('returns the expected output', () => {
      const input = [
            { data: [[1242362340000, 20]] },
        { data: [[1242362340000, 10], [1242362340001, 4], [1242362340002, 1]] },
        { data: [[1242362340000, 6], [1242362340001, 9]] },
        { data: [[1242362340000, 11], [1242362340001, 13], [1242362340002, 2]] },
      ];
      const output = {
        1242362340000: {
          x: 1242362340000,
          points: [20, 10, 6, 11],
          total: 47,
        },
        1242362340001: {
            x: 1242362340001,
          points: [0, 4, 9, 13],
          total: 26,
        },
        1242362340002: {
            x: 1242362340002,
          points: [0, 1, 0, 2],
          total: 3,
        }
      };

            responseToTimeseries(input).should.deep.equal(output);
    });
  });
});
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!