Search⌘ K
AI Features

Purification Exercises

Explore purification exercises to refine your understanding of pure functions. Learn to simplify JavaScript functions to single-line pure versions, enhancing code predictability and maintainability.

We'll cover the following...

Purify this function

Node.js
const assoc = (key, value, object) => {
object[key] = value;
};

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

Javascript (babel-node)
const getNames = (users) => {
console.log('getting names!');
return users.map((user) => user.name);
};

Purify this function

Node.js
const append = (item, list) => {
list.push(item);
return list;
};

Purify this function

Node.js
const sortAscending = (numbers) => numbers
.sort((a, b) => a > b);