Repository navigation
Expand file tree
/
Copy pathindex5.html
More file actions
40 lines (39 loc) · 1.58 KB
/
Copy pathindex5.html
File metadata and controls
40 lines (39 loc) · 1.58 KB
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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ejercicio 5 - Comprobar si un valor está en un array</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main class="lesson">
<header>
<h1>Ejercicio 5 · Comprobar si un valor está en un array</h1>
</header>
<section aria-labelledby="teoria">
<h2 id="teoria">Antes de empezar</h2>
<p><a href="https://www.w3schools.com/jsref/jsref_includes_array.asp" target="_blank" rel="noopener noreferrer">includes</a> comprueba si un valor aparece en el array.</p>
<pre><code>const tallas = ["S", "M", "L"];
console.log(tallas.includes("M")); // true
console.log(tallas.includes("XL")); // false</code></pre>
</section>
<section aria-labelledby="practica">
<h2 id="practica">Tu turno</h2>
<p>Abre la consola del navegador (<strong>F12 → Consola</strong>).</p>
<p>Explica por qué la primera búsqueda devuelve <em>true</em> y la segunda devuelve <em>false</em>. Indica qué tipo de dato devuelve includes.</p>
<p>Edita el último <code><script></code>, guarda el archivo y recarga la página.</p>
</section>
<details>
<summary>Resultado esperado</summary>
<pre>true
false</pre>
</details>
</main>
<script>
const muchosPeces = ["Dory", "Nemo", "Shipho", "Estrella"];
console.log(muchosPeces.includes("Nemo"));
console.log(muchosPeces.includes("Pepitillo"));
</script>
</body>
</html>