-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpunto3.html
85 lines (73 loc) · 2.22 KB
/
punto3.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
<title>Anagramas</title>
<style>
body {
background-color: #f0f0f0;
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 0;
}
h1 {
color: #007bff;
}
.container {
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
max-width: 400px;
margin: 20px auto;
text-align: center;
}
input[type="text"] {
width: 45%;
padding: 10px;
margin: 10px;
}
button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s;
font-size: 14px;
margin: 10px;
}
button:hover {
background-color: #0056b3;
}
p {
color: #777;
}
</style>
</head>
<body>
<div class="container">
<h1>Comprobador de Anagramas</h1>
<p>Ingresa dos palabras para comprobar si son anagramas:</p>
<input name="" id="p1" type="text" placeholder="Palabra1">
<input name="" id="p2" type="text" placeholder="Palabra2"> <br>
<button onclick="comprobarAnagramas()">Comprobar</button>
<p id="resultado"></p>
</div>
<script>
function comprobarAnagramas() {
var palabra1 = document.getElementById("p1").value;
var palabra2 = document.getElementById("p2").value;
function ordenarCadena(cadena) {
return cadena.split('').sort().join('');
}
if (ordenarCadena(palabra1) === ordenarCadena(palabra2)) {
document.getElementById("resultado").textContent = "¡Son anagramas!";
} else {
document.getElementById("resultado").textContent = "No son anagramas.";
}
}
</script>
</body>
</html>