18 lines
380 B
JavaScript
18 lines
380 B
JavaScript
|
|
const articlesApostrophes = {
|
|
'de' : 'd\'',
|
|
'le' : 'l\'',
|
|
'la' : 'l\''
|
|
}
|
|
export class Grammar {
|
|
|
|
static apostrophe(article, word) {
|
|
if (articlesApostrophes[article] && Grammar.startsWithVoyel(word)) {
|
|
return articlesApostrophes[article] + word
|
|
}
|
|
return article + ' ' + word;
|
|
}
|
|
static startsWithVoyel(word) {
|
|
return word.match(/^[aeiouy]/i)
|
|
}
|
|
} |