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!