Check if a string is present in array of strings - JavaScript


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 Check if a string is present in array of strings - JavaScript Reviewed by dasfrogpractice on 10:47 Rating: 5

No comments:

Theme images by mariusFM77. Powered by Blogger.
Youtube Channel Image
Dasfrog Subscribe To watch more Salesforce Training
Subscribe