My task involves incrementing the rank
value by one until the name
property changes. I am utilizing the page
and rank
properties to track when this change occurs.
In addition, I want to increment it once whenever the type
is not equal to none
, and then resume incrementing when it becomes equal to none
again.
I have almost achieved this using the provided code snippet, however, I seem to be lagging behind by one step. When the type
transitions back to none
, it fails to increment accordingly.
The desired output:
[
{ name: 'car', rank: 1, page: 1, type: 'other' },
{ name: 'car', rank: 2, page: 1, type: 'none' },
{ name: 'car', rank: 3, page: 2, type: 'none' },
{ name: 'car', rank: 4, page: 2, type: 'none' },
{ name: 'bike', rank: 1, page: 1, type: 'none' },
{ name: 'bike', rank: 2, page: 1, type: 'none' },
{ name: 'bike', rank: 3, page: 2, type: 'something_else' },
{ name: 'bike', rank: 3, page: 2, type: 'something_else' },
{ name: 'bike', rank: 3, page: 3, type: 'something_else' },
{ name: 'bike', rank: 4, page: 3, type: 'none' },
{ name: 'moto', rank: 1, page: 1, type: 'not_none' },
{ name: 'moto', rank: 1, page: 1, type: 'not_none' },
{ name: 'moto', rank: 2, page: 2, type: 'none' },
{ name: 'moto', rank: 3, page: 2, type: 'none' },
{ name: 'bus', rank: 1, page: 1, type: 'none' },
{ name: 'bus', rank: 2, page: 1, type: 'none' },
{ name: 'bus', rank: 3, page: 2, type: 'none' }
]