Skip to content

common prefix

Subhajit Sahu edited this page May 5, 2020 · 1 revision

Get common prefix of strings.

const commonPrefix = require('@extra-string/common-prefix');
// commonPrefix(<string-1>, <string-2>)

commonPrefix('peacock', 'peahen');
// 'pea'
commonPrefix('inception', 'interstellar');
// 'in'
commonPrefix('mars', 'tars');
// ''

extra-string

Clone this wiki locally