I have a use case where I have the array of object and I want to return the particular object based on the type. But the interesting part is that if one type is present then it should return the specific object and if it is not present it should return the object which has 2nd type and so on.
For me, priority is if type: video is present is should be returned and if it is not present then it should check further for type: file, if it is present then object with type:file should returned.
Ex: a = [<id:1, type:'video', format:'mp4'>, <id:2, type:'audio', format:'mp3'>,
<id:3, type:'file', format:'txt'>, <id:4, type:'exe', format:'exe'>]
In response, I should get the object of index 0 if type: video is present in a, else it should return object of index 2 if type: file is present and then it should return object of index 1.
Aucun commentaire:
Enregistrer un commentaire