0

Hi Could someone please help me with my problem below. I have an array:

var testarray = [AB_C_D, AC_B_D, PPLL_Y_N, PPMM_Y_N, PPDD_Y_N]

I want to remove object which contains PP* so that my final array will look like

var testarray = [AB_C_D, AC_B_D]

I cannot remove with index number because position of these objects will be different. Thanks in advance

1 Answer 1

2

var testarray = [
  'AB_C_D',
  'AC_B_D',
  'PPLL_Y_N',
  'PPMM_Y_N',
  'PPDD_Y_N'
]

const result = testarray.filter(str => !str.startsWith('PP'))
console.log(result)

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

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.