Back to tasksGet help with live coding in real time with Sobes Copilot
Junior — Senior
33
Преобразование параметров URL‑запроса в вложенный объект
Task condition
Создайте функцию, принимающую строку запроса из URL и возвращающую её параметры в виде вложенного JavaScript‑объекта.
const rawQuery = "user.name.firstname=Bob&user.name.lastname=Smith&user.favoritecolor=Light%20Blue&experiments.theme=dark";
function buildQueryObject(str) {
// реализация
}
buildQueryObject(rawQuery);
/*
{
'user': {
'name': {
'firstname': 'Bob',
'lastname': 'Smith'
},
'favoritecolor': 'Light Blue'
},
experiments: {
theme:'dark'
}
}
*/