I have a function CellDisplay
. Calling this function in another function forLaunch
, this forLaunch
function is getting called again in a loop Obj.forEach
which consist of array of object. If I log the key console.log(key)
in the forLaunch
function it's showing only first key. I need all the key to display. Here is the code below
Javascript
const CellDisplay = item => {
switch (item) {
case 'item1':
return 'one';
case 'item2':
return 'two';
case 'item3':
return 'three';
case 'item4':
return 'four';
case 'item5':
return 'five';
}
};
const forLaunch = lData => {
for (const key in lData) {
console.log(key);
return CellDisplay(key);
}
}
const Obj = [{
Id: 575,
items: {
item1: '2020-12-08T10:00:00.000+0000',
item2: '2020-11-12T00:00:00.000+0000',
item3: '2020-12-08T10:00:00.000+0000',
item4: null,
item5: '2020-12-08T10:00:00.000+0000'
},
active: false
}];
Obj.forEach(data => {
forLaunch(data.items);
});