Sobes.tech
Junior — Senior

Creating a new object with field selection by filter

livecode

Task condition

Function create, which:

  • Takes two objects: src — source data and mask — filter object;
  • Returns a new object result, including only those properties from src for which mask has the value true.
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 }