Skip to main content

Home > blockly > utils > string > commonWordPrefix

utils.string.commonWordPrefix() function

Given an array of strings, return the length of the common prefix. Words may not be split. Any space after a word is included in the length.

Signature:

export declare function commonWordPrefix(array: string[], opt_shortest?: number): number;

Parameters

ParameterTypeDescription
arraystring[]Array of strings.
opt_shortestnumber(Optional) Length of shortest string.

Returns:

number

Length of common prefix.