i have an object
const data = {
"name-uz": "name uz",
"desc-uz": "<p>desc uz</p>rn",
"name-en": "name en",
"desc-en": "<p>desc en</p>rn",
days: "5",
price: "2000",
extra_price: "1000",
};
i want to do this thing:
{
name: {
uz: "name-uz",
en: "name-en"
}
desc: {
uz: "desc-uz",
en: "desc-en"
}
}
how can i achieve this?
i have no idea what to do…
2
Answers
Use
Object.keys
to iterate through object propertiesUse
String.prototype.split
to split the stringHere is the shortest I could come up with.
I am assuming you have a name and a description in two languages and not just name uz and desc uz