In my attempt to contract an array for use in 'react-native-searchable-dropdown', I have encountered an issue while trying to push objects into the array. Here is the code snippet that I am struggling with:
let clone=[];
obj={{id:8,name:'Yyff'},{id:8,name:'Yyff'},{id:7,name:'Hsjdb56'},{id:6,name:'Suku'},{id:5,name:'Jira'},{id:4,name:'Suku '},{id:3,name:'Joseph'},{id:2,name:'Rosh'},{id:1,name:'Zulu'}}
let arr=Object.keys(obj);
for (var j = 0; j < obj.length; j++){
clone.push(obj[arr[j]);
}
The resulting 'clone' array appears as follows and has also been converted into an object (which is not desired):
Array [
"{id:8,name:'Yyff'}",
"{id:7,name:'Hsjdb56'}",
"{id:6,name:'Suku'}",
"{id:5,name:'Jira'}",
"{id:4,name:'Suku '}",
"{id:3,name:'Joseph'}",
"{id:2,name:'Rosh'}",
"{id:1,name:'Zulu'}"
]
Expected result:
clone=[{id:8,name:'Yyff'},{id:8,name:'Yyff'},{id:7,name:'Hsjdb56'},{id:6,name:'Suku'},{id:5,name:'Jira'},{id:4,name:'Suku '},{id:3,name:'Joseph'},{id:2,name:'Rosh'},{id:1,name:'Zulu'}]
Furthermore, the 'clone' should not be converted to an object since SearchableDropdown only accepts arrays like [{id:1, name:'heat'}].
If anyone could offer suggestions on how to achieve this, it would be greatly appreciated. I have tried various methods but haven't been able to obtain the desired outcome.