Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const check = ({ array, prop1, prop2 } = {}) => {
- if (!Array.isArray(array) || array.length === 0 ) {
- return;
- }
- const lastIndex = array.length - 1;
- const prevIndex = array.length - 2;
- const last = array[lastIndex];
- const prev = array[prevIndex];
- if (!prev) return;
- const isMatchWithLast = last.prop1 === prop1 && last.prop2 === prop2;
- const isMatchWithPrev = prev.prop1 === prop1 && prev.prop2 === prop2;
- return isMatchWithLast && isMatchWithPrev;
- }
Add Comment
Please, Sign In to add comment