Lekcja 2
This commit is contained in:
1 parent
ec2fc8b146
commit
6cc32f5146
6 files changed
+166
No files matched your search
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Lekcja 2 zadanie 3</title>
|
||||
<script>
|
||||
let text = "ten testowy tekst te słowa testowe testuje: te, ten, Bartek, potencjał, plater. Te."
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Podany tekst:</h1>
|
||||
<script>
|
||||
document.write(text)
|
||||
</script>
|
||||
|
||||
<h2>Szukane słowo:</h2>
|
||||
<script>
|
||||
let slowo = prompt("Podaj słowo", "te")
|
||||
let dozwolone_znaki = [' ', ',', '.']
|
||||
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
if (text.substring(i, i + slowo.length).toLowerCase() == slowo.toLowerCase() && text[i - 1] == ' ' && dozwolone_znaki.includes(text[i + slowo.length])) {
|
||||
document.write(`<u>${text.substring(i, i + slowo.length)}</u>`)
|
||||
i += slowo.length - 1
|
||||
} else {
|
||||
document.write(text[i])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user