Junior — Senior
Creating a new object with field selection by filter
livecode
Task condition
Function create, which:
- Takes two objects:
src— source data andmask— filter object; - Returns a new object
result, including only those properties fromsrcfor whichmaskhas the valuetrue.
const a = { fi: 1, k: 2, j: 5, o: 8, d: [3, 4, 5] };
const b = { fi: true, k: false, j: true };
const c = create(a, b); // Should return { fi: 1, j: 5 }