const arraySections = ['section 1'];
const sectionToCheck = 'section 2';
if (!arraySections.includes(sectionToCheck)) {
console.log(`${sectionToCheck} is not present in the array.`);
} else {
console.log(`${sectionToCheck} is present in the array.`);
}
Check if a string is present in array of strings - JavaScript
Reviewed by dasfrogpractice
on
10:47
Rating: 5
No comments: