contains

Checks if a string contains another string.

Description

vcc.contains(haystack: string, needle: string): boolean

Searches the needle in the haystack.

Parameters

haystack
It looks for the needle within this string.

needle
It looks for this element within the haystack.

Return values

Returns true if the needle is found in the haystack, false otherwise.

Example

We have a comma-separated list of allowed postal codes, and we want to check the given one.

const allowedValues = '2034,2579,1069,5173';
if (!vcc.contains(allowedValues, '2034')) {
    vcc.alert('The post code is not allowed');
}

There are no comments yet.

Comment

Subscribe to our newsletter
or Contact us!
Please note that by subscribing to our newsletter, you agree to receive regular email messages from VCC Live about service related news and updates. By subscribing to our newsletter, you also agree that VCC Live will use your data in accordance with the applicable Privacy Policy until you unsubscribe from the newsletter.