Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

filtering to check that a string is contained in the object in js

the best way is to use the includes method 

const objects = [{
	content: 'hello'
},{
	content: 'yellow'
},{
	content: 'red'
}
];

objects.filter(obj => obj.content.includes('ell'));

would return object at position 0 and 1
 
PREVIOUS NEXT
Tagged: #filtering #check #string #contained #object #js
ADD COMMENT
Topic
Name
1+6 =