var mycars = [['Ford', 'Fiesta', 'Manual', 'Rp. 160.000.000'],
['Ford', 'Fiesta', 'Manual', 'Rp. 163.000.000'],
['Ford', 'Fiesta', 'Automatic', 'Rp. 170.000.000'],
['Ford', 'Fiesta', 'Automatic', 'Rp. 175.000.000'],
['Ford', 'Fiesta', 'Automatic', 'Rp. 173.000.000'],
['Ford', 'Focus', 'Manual', 'Rp. 350.000.000'],
['Ford', 'Focus', 'Automatic', 'Rp. 400.000.000'],
['VW', 'Golf', 'Manual', 'Rp. 360.000.000'],
['VW', 'Golf', 'Manual', 'Rp. 365.000.000'],
['VW', 'Golf', 'Automatic', 'Rp. 390.000.000']];
Above is 2 dimensional array that has a lot of data repetition, that array need to simplify with provision as below:
- index data 0, must be full (no changes)
- data after index 0, if the value is the same as the previous index, change it to ''
- result data must remain in 2-dimensional array form
So the result will be as below
- index data 0, must be full (no changes)
- data after index 0, if the value is the same as the previous index, change it to ''
- result data must remain in 2-dimensional array form
So the result will show as below:
var mycars_compressed = [['Ford', 'Fiesta', 'Manual', 'Rp. 160.000.000'],
['', '', '', 'Rp. 163.000.000'],
['', '', 'Automatic', 'Rp. 170.000.000'],
...
['', '', 'Automatic', 'Rp. 400.000.000'],
['VW', 'Golf', 'Manual', 'Rp. 360.000.000'],
['', '', '', 'Rp. 365.000.000'],
...
];
And the result above could be decompressed again like the beginning.