JenMorgan / js-learning

0 stars 0 forks source link

Трансформировать в массив имён #53

Closed JenMorgan closed 4 years ago

JenMorgan commented 4 years ago
const vasya = { name: "Вася", age: 25 };
const petya = { name: "Петя", age: 30 };
const masha = { name: "Маша", age: 28 };

const users = [ vasya, petya, masha ];

function namesExtraction (arr) {
    return arr.map(({name}) => name);
}
JenMorgan commented 4 years ago
describe("namesExtraction", () => {
    it('extract all the names from the array of objects', () => {
        let arr = ["Вася", "Петя", "Маша"];
        assert.deepEqual(namesExtraction (users), arr);
    });
});