function select(arr, obj) { const result = {}; for (let name of arr) { if (name in obj) { result[name] = obj[name]; } } return result; }