0

I am developing a React Native application and I want to split this array, but I don't understand how to do that:

[{"dtCreatedOn": "2021-06-01T03:28:21.450Z", "flgIsActive": true, "inTagId": 2, "stTags": "Song"}, "3", "6", "7", "8"]

I want to get the value of the key inTagId and also the last integer values "3", "6", "7", "8" from this array

2 Answers 2

1
var a = [{"dtCreatedOn": "2021-06-01T03:28:21.450Z", "flgIsActive": true, "inTagId": 2, "stTags": "Song"}, "3", "6", "7", "8"]

var tagID  = a[0].inTagId

var b = Object.keys(a)
var lastInteger = b[(b.length-1)]
Sign up to request clarification or add additional context in comments.

Comments

1
var test =  [{"dtCreatedOn": "2021-06-01T03:26:44.910Z", "flgIsActive": true, "inTagId": 1, "stTags": "Emotion"},"4","5","6"]    
var tags = [];
test.map(function(ele) {
     if(typeof ele === 'object')
     {
        tags.push(ele.inTagId);
     }
     else
     {
         tags.push(ele)
     }
});

tags.join(',')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.