I have two comma-separated strings
list1 = 6,2
list2 = 1,2,4,5,6,7,9,12,13
I want to remove list1 elements from list2
Is there any function or anything that can achieve my desired result.
I have two comma-separated strings
list1 = 6,2
list2 = 1,2,4,5,6,7,9,12,13
I want to remove list1 elements from list2
Is there any function or anything that can achieve my desired result.
Split into separate items, filter and join:
const list1 = '6,2',
list2 = '1,2,4,5,6,7,9,12,13',
result = list2
.split(',')
.filter(n =>
!list1
.split(',')
.includes(n))
.join(',')
console.log(result)