generated from the-code-challenge/geringozo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (37 loc) · 1.01 KB
/
index.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const geringozo = function (str) {
let splited = str.split("")
let string = ''
let qfound = false
let gfound = false
splited.forEach(el => {
switch (el) {
case 'g':
return gfound = true
case 'q':
return qfound = true
case 'a':
return string += 'apa'
case 'i':
return string += 'ipi'
case 'o':
return string += 'opo'
case 'e':
return string += 'epe'
case 'u':
if (qfound) {
qfound = false
return string += 'qu'
} else if (gfound) {
qfound = false
return string += 'gu'
} else {
return string += 'upu'
}
default:
return string += el
}
})
console.log("Splited ", string)
return string
}
module.exports = geringozo