0

I am trying to check the 2nd level deep of array element and i tried .intersect and map seems i am not doing it well. My code look like this Icon is an object with element inside URL and i want to make sure that this URL is not empty with the below filter.

response.RelatedTopics.filter(function (el) {
  return el.Icon !== '' && el.URL !== '' && el.Text !== '';

})

But when i add to element of Icon which is this uRL i usually get error and this is the condition i want to cheeck below.

el.Icon.URL !== ''

But when i add .URL i am getting error. Someone help pls.

2 Answers 2

1

Try this :

return el.Icon && el.Icon.URL && el.Text

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it worked there was a typo in my code earlier on!
0

The answer by Mumin Korcan worked but i finally constructed it like this. and i got what i wanted no difference though! Thanks Mumin Korcan

return el.Icon && el.Icon.URL && el.Text !== '';

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.