Junior — Senior
Refactor the add function to make it pure
livecode
Condición de la tarea
The task is to clean up the add function by removing everything that violates the principles of a pure function.
let x = 2;
const add = async (params, y) => {
params.value = y;
y += y + Math.random(params.value);
x += y;
console.log('doubling', x);
const { data } = await axios({ method: 'get', url: '/' });
const elem = document.getElementById('elem');
const width = elem.getBoundingClientRect().width;
return x + data + width;
};
add({ value: 4 }, 1);