...

/

Solution Review: Let's Add Properties

Solution Review: Let's Add Properties

This lesson will explain the solution to the problem in the previous lesson.

We'll cover the following...

Solution #

Press + to interact
const func = (key, value, object) => ({
...object,
[key] : value
});
function test(){
const car = {
name: 'Toyota'
};
const answer = func('model', 88, car);
console.log({car,answer});
}
test()

Explanation #

In this challenge, you had to convert the following impure function into a pure function.

Press + to interact
const func = (key, value, object) => {
object[key] = value
};
function test(){
const car = {
name: 'Toyota'
};
const answer = func('model', 88, car);
console.log({car,answer});
}
test()

As you can see, the function updates ...