Get parent from its child in object structure - javascript

I have an object which looks something like this:
{
"11": {
"id": 11,
"parent_product": 0,
"product_name": "WebStore",
"product_price_city": null,
"child": {
"12": {
"id": 12,
"parent_product": 11,
"product_name": "WebStore - Single",
"product_price_city": 500
},
"13": {
"id": 13,
"parent_product": 11,
"product_name": "WebStore - Full",
"product_price_city": 2500
}
}
}
}
Here, the key 11 has two childs: 12 and 13.
In a different object which looks like this:
{
"316":
{
"id": 316,
"product_id": 13,
"sold_by": 1,
"product_price": 5000,
"subscription_month": 3,
"updated_by": 0,
"created_at": 1449573556
},
"317":
{
"id": 317,
"product_id": 12,
"sold_by": 1,
"product_price": 5000,
"subscription_month": 3,
"updated_by": 0,
"created_at": 1449573556
}
}
I here the product_id is either 12 or 13, that is it will always be a child.
I need to get the parent id of 12 and 13, so I can access they the first object.
data.11
How can I get it in JavaScript?

Just get the properties and iterate over it.
var object1 = {
"11": { "id": 11, "parent_product": 0, "product_name": "WebStore", "product_price_city": null, "child": { "12": { "id": 12, "parent_product": 11, "product_name": "WebStore - Single", "product_price_city": 500 },
"13": { "id": 13, "parent_product": 11, "product_name": "WebStore - Full", "product_price_city": 2500 } } },
"15": { "id": 15, "parent_product": 0, "product_name": "WebStore", "product_price_city": null, "child": undefined },
"17": { "id": 17, "parent_product": 0, "product_name": "WebStore", "product_price_city": null }
},
key;
function getParent(id, object) {
var k;
Object.keys(object).some(function (a) {
if (object[a].child && id in object[a].child) {
k = a;
return true;
}
});
return k;
}
document.write(getParent('12', object1) + '<br>'); // '11'
key = getParent('42', object1);
if (typeof key === 'undefined') {
document.write('no key found');
}

Related

How to make a tree select option - reactjs

I want to make a select/option nested with a json:
{
"id": 11,
"title": "A",
"parent_id": null,
"is_active": 1,
"children": [
{
"id": 12,
"title": "B",
"parent_id": 11,
"is_active": 1,
"children": [
{
"id": 13,
"title": "C",
"parent_id": 12,
"is_active": 1
},
{
"id": 14,
"title": "D",
"parent_id": 12,
"is_active": 1
},
{
"id": 15,
"title": "G",
"parent_id": 12,
"is_active": 1
},
{
"id": 16,
"title": "H",
"parent_id": 12,
"is_active": 1
},
{
"id": 62,
"title": "I",
"parent_id": 12,
"is_active": 1
}
]
},
{
"id": 17,
"title": "J",
"parent_id": 11,
"is_active": 1,
"children": [
{
"id": 18,
"title": "K",
"parent_id": 17,
"is_active": 1
},
{
"id": 19,
"title": "L",
"parent_id": 17,
"is_active": 1
},
{
"id": 20,
"title": "M",
"parent_id": 17,
"is_active": 1
},
{
"id": 21,
"title": "N",
"parent_id": 17,
"is_active": 1
}
]
}
]
}
I want to create below result:
<select>
<optgroup label=“A”>
<optgroup label=“B”>
<option>C</option>
<option>D</option>
<option>G</option>
</optgroup>
<optgroup label=“J”>
<option>K</option>
<option>L</option>
<option>M</option>
</optgroup>
</optgroup>
</select>
my code:
console.log(this.makeTreeOptionSele(undefined,data))
makeTreeOptionSele(result, obj) {
if (obj.children) {
result += "<optgroup label={"+obj.title+"}>"
{this.getOptionChilds(obj.children)}
"</optgroup>"
}
if(result)
return result
}
getOptionChilds(childrens) {
var result = null
for (var i = 0; i < childrens.length; ++i) {
var child = childrens[i]
result +="<option value={"+child.id+"}>{"+child.title+"}</option>"
if (child.children) {
return this.makeTreeOptionSele(result, child)
}
}
return result
}
but it does't return result.
function makeTreeOption(tree) {
let ouput = `<optgroup label="${tree.title}">`;
if (tree['children']) {
tree.children.forEach(children => {
if (children['children']) {
ouput += makeTreeOption(children);
} else {
ouput += `<option>${children.title}</option>`;
}
});
}
ouput += `</optgroup>`;
return ouput;
}

How to handle complex tree array and traverse new arrays?

Object index 0:
If select===1, the third-level array length have two select===1, the two-level push to selected:[8,9] and checkedAll:true
the one-level checkedAll:true and push to selected:[7]
Object index 1: Same as above Object index 0
Object index 2:
If select===1, the two-level push to selected:[15], the third-level child array length > two-level array selected length, indeterminate:true
and the one-level indeterminate:true
I am trying to solve the complex json, don't know how to implement the following result array.
The correct result is printed as follows
[{
"id": 1,
"pid": 0,
"name": "a",
"select": 0,
"checkedAll": true,
"indeterminate": false,
"selected": [7],
"child": [{
"id": 7,
"pid": 1,
"name": "a-1",
"select": 1,
"checkedAll": true,
"indeterminate": false,
"selected": [8, 9],
"child": [{
"id": 8,
"pid": 7,
"name": "a-1-2",
"select": 1
},
{
"id": 9,
"pid": 7,
"name": "a-2-2",
"select": 1
}
]
}]
},
{
"id": 2,
"pid": 0,
"name": "b",
"select": 1,
"checkedAll": true,
"indeterminate": false,
"selected": [10],
"child": [{
"id": 10,
"pid": 2,
"name": "b-1",
"select": 1,
"checkedAll": true,
"indeterminate": false,
"selected": [11, 12],
"child": [{
"id": 11,
"pid": 10,
"name": "b-1-1",
"select": 1
},
{
"id": 12,
"pid": 10,
"name": "b-1-2",
"select": 1
}
]
}]
},
{
"id": 3,
"pid": 0,
"name": "c",
"select": 0,
"checkedAll": false,
"indeterminate": true,
"selected": [],
"child": [{
"id": 13,
"pid": 3,
"name": "c-1",
"select": 1,
"checkedAll": false,
"indeterminate": true,
"selected": [15],
"child": [{
"id": 14,
"pid": 13,
"name": "c-1-1",
"select": 0
},
{
"id": 15,
"pid": 13,
"name": "c-1-2",
"select": 1
}
]
}]
}
]
My code:
var result = [{
"id": 1,
"pid": 0,
"name": "a",
"select": 0,
"child": [{
"id": 7,
"pid": 1,
"name": "a-1",
"select": 1,
"child": [{
"id": 8,
"pid": 7,
"name": "a-1-2",
"select": 1
},
{
"id": 9,
"pid": 7,
"name": "a-2-2",
"select": 1
}
]
}]
},
{
"id": 2,
"pid": 0,
"name": "b",
"select": 0,
"child": [{
"id": 10,
"pid": 2,
"name": "b-1",
"select": 0,
"child": [{
"id": 11,
"pid": 10,
"name": "b-1-1",
"select": 1
},
{
"id": 12,
"pid": 10,
"name": "b-1-2",
"select": 1
}
]
}]
},
{
"id": 3,
"pid": 0,
"name": "c",
"select": 0,
"child": [{
"id": 13,
"pid": 3,
"name": "c-1",
"select": 1,
"child": [{
"id": 14,
"pid": 13,
"name": "c-1-1",
"select": 0
},
{
"id": 15,
"pid": 13,
"name": "c-1-2",
"select": 1
}
]
}]
}
]
var selected = []
for (let i = 0; i < result.length; i++) {
const a1 = result[i].child
for (let j = 0; j < a1.length; j++) {
console.log(a1[j].name)
const a2 = a1[j].child
for (let k = 0; k < a2.length; k++) {
if (a1[j].id === a2[k].pid) {
if (a2[k].select === 1) {
console.log(a1[j].id)
console.log(a2[k].name)
console.log('yyyyyyyy', a2[k].id)
}
}
}
}
}
console.log(result)
described as follows
And what about this (not sure if it is possible to change items order), you can click accept under voting arrows in case you like it:
var selected = [], result = input();
for (let i = 0; i < result.length; i++) {
const a1 = result[i].child
for (let j = 0; j < a1.length; j++) {
const a2 = a1[j].child
for (let k = 0; k < a2.length; k++) {
if (a1[j].id === a2[k].pid) {
if (a2[k].select === 1) {
let selected = a1[j].selected || [];
selected.push(a2[k].id)
a1[j].selected = selected;
if (selected.length == a2.length) {
result[i].checkedAll = true;
a1[j].checkedAll = true;
}
result[i].selected = a1[j].id;
}
}
}
result[i].indeterminate = !result[i].checkedAll;
a1[j].indeterminate = !a1[j].checkedAll;
}
}
console.log(JSON.stringify(result, null, 2))
function input() {
return [{
"id": 1,
"pid": 0,
"name": "a",
"select": 0,
"child": [{
"id": 7,
"pid": 1,
"name": "a-1",
"select": 1,
"child": [{
"id": 8,
"pid": 7,
"name": "a-1-2",
"select": 1
},
{
"id": 9,
"pid": 7,
"name": "a-2-2",
"select": 1
}
]
}]
},
{
"id": 2,
"pid": 0,
"name": "b",
"select": 0,
"child": [{
"id": 10,
"pid": 2,
"name": "b-1",
"select": 0,
"child": [{
"id": 11,
"pid": 10,
"name": "b-1-1",
"select": 1
},
{
"id": 12,
"pid": 10,
"name": "b-1-2",
"select": 1
}
]
}]
},
{
"id": 3,
"pid": 0,
"name": "c",
"select": 0,
"child": [{
"id": 13,
"pid": 3,
"name": "c-1",
"select": 1,
"child": [{
"id": 14,
"pid": 13,
"name": "c-1-1",
"select": 0
},
{
"id": 15,
"pid": 13,
"name": "c-1-2",
"select": 1
}
]
}]
}
];
}

Remove duplicate objects from an array but merge nested objects

Currently have an array of objects which contain game releases. However game releases can happen on multiple platforms and these appear as separate objects within the array. I'm looking to remove duplicate games by comparing the game id but merge the platforms object
I have tried using the reduce function which successfully removes duplicate objects by game id but I'm unable to adapt this to merge platforms
const filteredArr = data.reduce((acc, current) => {
const x = acc.find(item => item.game.id === current.game.id);
if (!x) {
return acc.concat([current]);
} else {
return acc;
}
}, []);
Current Array:
const data = [{
"id": 157283,
"date": 1553212800,
"game": {
"id": 76882,
"name": "Sekiro: Shadows Die Twice",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": {"id": 48, "name": "PlayStation 4"},
"region": 8,
"y": 2019
}, {
"id": 12,
"date": 1553212800,
"game": {
"id": 76832,
"name": "Spiderman",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": {"id": 6, "name": "PC (Microsoft Windows)"},
"region": 8,
"y": 2019
}, {
"id": 157283,
"date": 1553212800,
"game": {
"id": 76882,
"name": "Sekiro: Shadows Die Twice",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": {"id": 48, "name": "Xbox"},
"region": 8,
"y": 2019
}]
Expected format after merge:
[{
"id": 157283,
"date": 1553212800,
"game": {
"id": 76882,
"name": "Sekiro: Shadows Die Twice",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platforms": ["PlayStation", "Xbox"],
"region": 8,
"y": 2019
}, {
"id": 12,
"date": 1553212800,
"game": {
"id": 76832,
"name": "Spiderman",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platforms": ["Playstation"],
"region": 8,
"y": 2019
}]
You were really close, you just need to change the logic a bit. You can try something like the following; an example - https://repl.it/#EQuimper/ScaryBumpyCircle
const filteredArr = data.reduce((acc, current) => {
const x = acc.find(item => item.game.id === current.game.id);
if (!x) {
current.platform = [current.platform]
acc.push(current);
} else {
x.platform.push(current.platform);
}
return acc;
}, []);
The return value is
[
{
"id": 157283,
"date": 1553212800,
"game": {
"id": 76882,
"name": "Sekiro: Shadows Die Twice",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": [
{
"id": 48,
"name": "PlayStation 4"
},
{
"id": 48,
"name": "Xbox"
}
],
"region": 8,
"y": 2019
},
{
"id": 12,
"date": 1553212800,
"game": {
"id": 76832,
"name": "Spiderman",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": [
{
"id": 6,
"name": "PC (Microsoft Windows)"
}
],
"region": 8,
"y": 2019
}
]
If you want to have just an array of platform strings, go with
const filteredArr = data.reduce((acc, current) => {
const x = acc.find(item => item.game.id === current.game.id);
if (!x) {
current.platform = [current.platform.name]
acc.push(current);
} else {
x.platform.push(current.platform.name);
}
return acc;
}, []);
And now the return value is
[
{
"id": 157283,
"date": 1553212800,
"game": {
"id": 76882,
"name": "Sekiro: Shadows Die Twice",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": [
"PlayStation 4",
"Xbox"
],
"region": 8,
"y": 2019
},
{
"id": 12,
"date": 1553212800,
"game": {
"id": 76832,
"name": "Spiderman",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": [
"PC (Microsoft Windows)"
],
"region": 8,
"y": 2019
}
]
You could separate platform of the object and look if you have an object with the same id and add the platfor tho the array, of not create a new data set.
const
data = [{ id: 157283, date: 1553212800, game: { id: 76882, name: "Sekiro: Shadows Die Twice", popularity: 41.39190295640344 }, human: "2019-Mar-22", m: 3, platform: { id: 48, name: "PlayStation 4" }, region: 8, y: 2019 }, { id: 12, date: 1553212800, game: { id: 76832, name: "Spiderman", popularity: 41.39190295640344 }, human: "2019-Mar-22", m: 3, platform: { id: 6, name: "PC (Microsoft Windows)" }, region: 8, y: 2019 }, { id: 157283, date: 1553212800, game: { id: 76882, name: "Sekiro: Shadows Die Twice", popularity: 41.39190295640344 }, human: "2019-Mar-22", m: 3, platform: { id: 48, name: "Xbox" }, region: 8, y: 2019 }],
result = data.reduce((r, { platform, ...o }) => {
var temp = r.find(({ id }) => id === o.id);
if (!temp) r.push(temp = { ...o, platforms: [] });
temp.platforms.push(platform);
return r;
}, []);
console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }
Please take a look:
const data = [ { "id": 157283,
"date": 1553212800,
"game": {
"id": 76882,
"name": "Sekiro: Shadows Die Twice",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": {
"id": 48,
"name": "PlayStation 4"
},
"region": 8,
"y": 2019
},
{
"id": 12,
"date": 1553212800,
"game": {
"id": 76832,
"name": "Spiderman",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": {
"id": 6,
"name": "PC (Microsoft Windows)"
},
"region": 8,
"y": 2019
},{ "id": 157283,
"date": 1553212800,
"game": {
"id": 76882,
"name": "Sekiro: Shadows Die Twice",
"popularity": 41.39190295640344
},
"human": "2019-Mar-22",
"m": 3,
"platform": {
"id": 48,
"name": "Xbox"
},
"region": 8,
"y": 2019
},
]
const filteredArr = data.reduce((acc, current) => {
const x = acc.find(item => item.game.id === current.game.id);
if (!x) {
current.platform = [current.platform.name]
return acc.concat([current]);
} else {
x.platform.push(current.platform.name);
return acc;
}
}, []);
console.log(filteredArr);
Here is another solution, using forEach instead of reduce. This makes use of a lookup hash that makes if faster for larger amounts of data then using find.
const data = [{"id": 157283, "date": 1553212800, "game": {"id": 76882, "name": "Sekiro: Shadows Die Twice", "popularity": 41.39190295640344}, "human": "2019-Mar-22", "m": 3, "platform": {"id": 48, "name": "PlayStation 4"}, "region": 8, "y": 2019}, {"id": 12, "date": 1553212800, "game": {"id": 76832, "name": "Spiderman", "popularity": 41.39190295640344}, "human": "2019-Mar-22", "m": 3, "platform": {"id": 6, "name": "PC (Microsoft Windows)"}, "region": 8, "y": 2019}, {"id": 157283, "date": 1553212800, "game": {"id": 76882, "name": "Sekiro: Shadows Die Twice", "popularity": 41.39190295640344}, "human": "2019-Mar-22", "m": 3, "platform": {"id": 48, "name": "Xbox"}, "region": 8, "y": 2019}];
let result = {};
data.forEach(({platform, ...release}) => {
release.platforms = [platform.name];
const releaseLookup = result[release.game.id];
if (!releaseLookup) {
result[release.game.id] = release;
} else {
releaseLookup.platforms.push(...release.platforms);
}
});
console.log(Object.values(result));

Using angularjs forEach loops

I am getting this type of json in my $scope of angularjs:
$scope.someStuff = {
"id": 2,
"service": "bike",
"min": "22",
"per": "100",
"tax": "1",
"categoryservices": [
{
"id": 32,
"category": {
"id": 1,
"name": "software"
}
},
{
"id": 33,
"category": {
"id": 2,
"name": "hardware"
}
},
{
"id": 34,
"category": {
"id": 3,
"name": "waterwash"
}
}
]
}
I want to use angularjs forEach loop and i want to get only category name,
My expected output:
[{"name":"software"}, {"name":"hardware"}, {"name":"waterwash"}]
You can use Array.map()
The map() method creates a new array with the results of calling a provided function on every element in the calling array.
$scope.someStuff.categoryservices.map((x) => { return { name: x.category.name}})
var obj = {
"id": 2,
"service": "bike",
"min": "22",
"per": "100",
"tax": "1",
"categoryservices": [{
"id": 32,
"category": {
"id": 1,
"name": "software"
}
},
{
"id": 33,
"category": {
"id": 2,
"name": "hardware"
}
},
{
"id": 34,
"category": {
"id": 3,
"name": "waterwash"
}
}
]
};
console.log(obj.categoryservices.map((x) => {
return {
name: x.category.name
}
}))
You can use map method by passing a callback function as parameter.
const someStuff = { "id": 2, "service": "bike", "min": "22", "per": "100", "tax": "1", "categoryservices": [ { "id": 32, "category": { "id": 1, "name": "software" } }, { "id": 33, "category": { "id": 2, "name": "hardware" } }, { "id": 34, "category": { "id": 3, "name": "waterwash" } } ] }
let array = someStuff.categoryservices.map(function({category}){
return {'name' : category.name}
});
console.log(array);

How to find all unique paths in tree structure

root1
child1
child2
grandchild1
grandchild2
child3
root2
child1
child2
grandchild1
greatgrandchild1
I have an object array like tree structure like above, I want to get all unique paths in like this
Food->Dry Food Items->Local Dry Food Items
Food->Dry Food Items->Thai Dry Food Items
Food->Dry Food Items->Others
Food->Fruits
------
------
This is my object
[
{
"id": 1,
"name": "Food",
"parent_id": 0,
"children": [
{
"id": 5,
"name": "Dry Food Items",
"parent_id": 1,
"children": [
{
"id": 11,
"name": "Local Dry Food Items",
"parent_id": 5
},
{
"id": 12,
"name": "Thai Dry Food Items",
"parent_id": 5
},
{
"id": 60,
"name": "Others",
"parent_id": 5
}
]
},
{
"id": 6,
"name": "Fruits",
"parent_id": 1
},
{
"id": 7,
"name": "LG Branded",
"parent_id": 1
},
{
"id": 8,
"name": "Meat",
"parent_id": 1
},
{
"id": 9,
"name": "Sea food",
"parent_id": 1
},
{
"id": 10,
"name": "Vegetables",
"parent_id": 1,
"children": [
{
"id": 14,
"name": "Local Vegetables",
"parent_id": 10
},
{
"id": 15,
"name": "Thai Vegetables",
"parent_id": 10
}
]
},
{
"id": 38,
"name": "Frozen",
"parent_id": 1
},
{
"id": 39,
"name": "IP Kitchen",
"parent_id": 1,
"children": [
{
"id": 40,
"name": "IP Meat",
"parent_id": 39
},
{
"id": 41,
"name": "IP Starter",
"parent_id": 39
},
{
"id": 42,
"name": "IP Ingredients",
"parent_id": 39
},
{
"id": 43,
"name": "IP Sauce",
"parent_id": 39
},
{
"id": 44,
"name": "IP Seafood",
"parent_id": 39
},
{
"id": 45,
"name": "IP Starter",
"parent_id": 39
},
{
"id": 46,
"name": "IP Desert",
"parent_id": 39
}
]
}
]
},
{
"id": 2,
"name": "Beverage",
"parent_id": 0,
"children": [
{
"id": 16,
"name": "Bar",
"parent_id": 2
},
{
"id": 17,
"name": "Coffee & Tea",
"parent_id": 2
},
{
"id": 18,
"name": "In Can",
"parent_id": 2
},
{
"id": 19,
"name": "Water",
"parent_id": 2
},
{
"id": 47,
"name": "IP Bar",
"parent_id": 2
}
]
},
{
"id": 3,
"name": "Disposable",
"parent_id": 0,
"children": [
{
"id": 21,
"name": "Disposable",
"parent_id": 3
}
]
},
{
"id": 4,
"name": "SOE",
"parent_id": 0,
"children": [
{
"id": 20,
"name": "Cleaning Materials",
"parent_id": 4
},
{
"id": 22,
"name": "Chinaware",
"parent_id": 4
}
]
}
];
I get to all the nodes in the tree
function traverse(categories) {
categories.forEach(function (category) {
if (category.children && category.children.length) {
traverse(category.children);
}
else {
}
}, this);
}
You can use recursion and create a function using forEach loop.
var arr = [{"id":1,"name":"Food","parent_id":0,"children":[{"id":5,"name":"Dry Food Items","parent_id":1,"children":[{"id":11,"name":"Local Dry Food Items","parent_id":5},{"id":12,"name":"Thai Dry Food Items","parent_id":5},{"id":60,"name":"Others","parent_id":5}]},{"id":6,"name":"Fruits","parent_id":1},{"id":7,"name":"LG Branded","parent_id":1},{"id":8,"name":"Meat","parent_id":1},{"id":9,"name":"Sea food","parent_id":1},{"id":10,"name":"Vegetables","parent_id":1,"children":[{"id":14,"name":"Local Vegetables","parent_id":10},{"id":15,"name":"Thai Vegetables","parent_id":10}]},{"id":38,"name":"Frozen","parent_id":1},{"id":39,"name":"IP Kitchen","parent_id":1,"children":[{"id":40,"name":"IP Meat","parent_id":39},{"id":41,"name":"IP Starter","parent_id":39},{"id":42,"name":"IP Ingredients","parent_id":39},{"id":43,"name":"IP Sauce","parent_id":39},{"id":44,"name":"IP Seafood","parent_id":39},{"id":45,"name":"IP Starter","parent_id":39},{"id":46,"name":"IP Desert","parent_id":39}]}]},{"id":2,"name":"Beverage","parent_id":0,"children":[{"id":16,"name":"Bar","parent_id":2},{"id":17,"name":"Coffee & Tea","parent_id":2},{"id":18,"name":"In Can","parent_id":2},{"id":19,"name":"Water","parent_id":2},{"id":47,"name":"IP Bar","parent_id":2}]},{"id":3,"name":"Disposable","parent_id":0,"children":[{"id":21,"name":"Disposable","parent_id":3}]},{"id":4,"name":"SOE","parent_id":0,"children":[{"id":20,"name":"Cleaning Materials","parent_id":4},{"id":22,"name":"Chinaware","parent_id":4}]}]
function getNames(data) {
var result = [];
function loop(data, c) {
data.forEach(function (e) {
var name = !c.length ? e.name : c + '->' + e.name;
if (e.children) { loop(e.children, name); }
else {
result.push({ name: name });
}
});
}
loop(data, '');
return result;
}
console.log(getNames(arr))

Categories

Resources