-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (60 loc) · 1.86 KB
/
index.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Pangram Analyzer</title>
<style>
body {
font-family: sans-serif;
}
h1 {
text-align: center;
}
textarea {
width: 100%;
height: 100px;
}
button {
margin-top: 10px;
}
#output {
margin-top: 10px;
font-weight: bold;
}
</style>
</head>
<body>
<h1>Панграм проверувач</h1>
<p>Внесете го вашиот панграм:</p>
<textarea id="input"></textarea>
<button onclick="analyze()">Провери</button>
<p id="output"></p>
<script>
function analyze() {
const input = document.getElementById("input").value;
const letters = {};
for (let i = 0; i < input.length; i++) {
const letter = input[i].toLowerCase();
if (/[абвгдѓежзѕијклљмнњопрстќуфхцчџш]/.test(letter)) {
letters[letter] = true;
}
}
const missingLetters = [];
let pangramLetters = 0;
for (let letter of "абвгдѓежзѕијклљмнњопрстќуфхцчџш") {
if (letters[letter]) {
pangramLetters++;
} else {
missingLetters.push(letter);
}
}
const totalCharacters = input.replace(/[^абвгдѓежзѕијклљмнњопрстќуфхцчџш]/gi, "").length;
if (missingLetters.length === 0) {
document.getElementById("output").innerHTML = "Ова е панграм од " + pangramLetters + " букви, и вкупно " + totalCharacters + " карактери";
} else {
document.getElementById("output").innerHTML = "Букви кои недостигаат: " + missingLetters.join(", ");
}
}
</script>
</body>
</html>