Skip to content

Instantly share code, notes, and snippets.

View vickey-dev's full-sized avatar

Vickey | விக்னேஸ்வரன் vickey-dev

View GitHub Profile
/**
* @desc consecutiveRoleIdsCountListWithIndex:
* -> will check if each element is the same as the one before it in the array
* -> if yes it will skip that id & increment the repeated count by +1,
* -> it will preserve the non-consecutive duplicates also
* output : [{"roleId":"5fdf1c022a4b9dea","repeatedCount":2,"index":0},{"roleId":"cb1c0e2f-aabd-303b-8db4-94458cf0c3ca","repeatedCount":1,"index":2},{"roleId":"5fdf1c022a4b9dea","repeatedCount":1,"index":3},{"roleId":"da0384e0-3e89-3df9-9f7f-191e5766d36b","repeatedCount":1,"index":4}]
* @param arrayList
* @returns []
*/
function consecutiveRoleIdsCountListWithIndex(arrayList) {