Purification Exercises

Exercises on making pure versions of impure functions.

Purify this function

Press + to interact
const assoc = (key, value, object) => {
object[key] = value;
};

Purify this function. It should work in just one line!

Press + to interact
const getNames = (users) => {
console.log('getting names!');
return users.map((user) => user.name);
};

Purify this function

Press + to interact
const append = (item, list) => {
list.push(item);
return list;
};

Purify this function

Press + to interact
const sortAscending = (numbers) => numbers
.sort((a, b) => a > b);