Назад к задачамПолучайте помощь с лайвкодингом в реальном времени с Sobes Copilot
Junior — Senior
6
Refactor the add function to make it pure
Условие задачи
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);