Skip to content

Instantly share code, notes, and snippets.

@jherax
jherax / arrayFilterFactory.1.ts
Last active February 20, 2025 05:05
Filters an array of objects with multiple match-criteria.
type FilterOperator = 'AND' | 'OR';
type FiltersBy<T> = {
[K in keyof T]?: (value: T[K]) => boolean;
};
/**
* Factory function that creates a specialized function to filter
* arrays, by validating all filters (AND operator),
* or validating just one of the filters (OR operator).
* @param operator Method to validate all filters: AND, OR
@MariaSzubski
MariaSzubski / compareArrays.js
Created July 21, 2016 21:51
Compare each value between two arrays. #hackerrank #warmup
/*
Solution for HackerRank > Algorithms > Warmup > Compare the Triplets
https://www.hackerrank.com/challenges/compare-the-triplets
*/
function main() {
var A = [5,6,7];
var B = [3,6,10];
// Set counters to '0'