-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (25 loc) · 792 Bytes
/
script.js
File metadata and controls
30 lines (25 loc) · 792 Bytes
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
function processText() {
const text = document.getElementById('text').value.trim();
const operation = document.getElementById('operation').value;
let result = '';
if (operation === 'encrypt') {
result = encrypt(text);
} else {
result = decrypt(text);
}
document.getElementById('result').innerText = result;
}
function encrypt(text) {
return text.replace(/e/g, 'enter')
.replace(/i/g, 'imes')
.replace(/a/g, 'ai')
.replace(/o/g, 'ober')
.replace(/u/g, 'ufat');
}
function decrypt(text) {
return text.replace(/enter/g, 'e')
.replace(/imes/g, 'i')
.replace(/ai/g, 'a')
.replace(/ober/g, 'o')
.replace(/ufat/g, 'u');
}