Check if string contains DDA (JAVASCRIPT)


function containsDDAInParts(str) {
    // Split the string by semicolon
    const parts = str.split(';');
    // Check if any part is exactly 'DDA' after trimming whitespace
    return parts.some(part => part.trim() === 'DDA');
}

// Test cases
const string1 = 'DDA;ABC DDA;1234 DDA';
const string2 = 'ABC DDA;1234 DDA';

// Check if the strings contain 'DDA' in any part
console.log(containsDDAInParts(string1));  // True, because the first part is exactly 'DDA'
console.log(containsDDAInParts(string2));  // False, because no part is exactly 'DDA'
Check if string contains DDA (JAVASCRIPT) Check if string contains DDA (JAVASCRIPT) Reviewed by dasfrogpractice on 03:47 Rating: 5

No comments:

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