-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path17.js
28 lines (15 loc) · 781 Bytes
/
17.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//18) Programa una función que dada una cadena de texto cuente el número de vocales y consonantes, pe.
//miFuncion("Hola Mundo") devuelva Vocales: 4, Consonantes: 5.
function vocales_consonantes (string) {
if (!string || typeof string !== "string") return "ingresa un texto valido";
let regExpVoc = /[aeiouáéíóúäëïöüAEIOUÁÉÍÓÚÄËÏÖÜ]/g
let regExpCon = /[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]/g
let numero_vocales = string.match(regExpVoc) === null ? 0 : string.match(regExpVoc).length
let numero_consonantes = string.match(regExpCon) === null? 0: string.match(regExpCon).length
return console.info(
string,
numero_vocales,
numero_consonantes
)
}
vocales_consonantes("tswe")