Please help me write this JavaScript function. Thank you very much! pick(source, keys) Creates an object composed of the picked source properties. Parameters source - Any JavaScript Object keys - An...


Please help me write this JavaScript function. Thank you very much!




  1. pick(source, keys)


    Creates an object composed of the picked source properties.


    Parameters



    • source - Any JavaScript Object

    • keys - An array of JavaScript Strings


    Return Value


    A new Object containing all of the properties of source listed in keys. If a key is listed in keys, but is not defined in source, then that property is not added to the new Object.


    Examples


    pick({ foo: 1, bar: 2, baz: 3 }, ['foo', 'baz']) // -> { foo: 1, baz: 3 } pick({ qux: 4, corge: 5 }, ['bar', 'grault']) // -> {} pick({ bar: 2 }, ['foo', 'bar', 'baz']) // -> { bar: 2 }



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here