Repository navigation
Expand file tree
/
Copy pathindex5b.html
More file actions
58 lines (55 loc) · 2.31 KB
/
Copy pathindex5b.html
File metadata and controls
58 lines (55 loc) · 2.31 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ejercicio 5b - Devolver el resultado de una búsqueda</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main class="lesson">
<header>
<h1>Ejercicio 5b · Devolver el resultado de una búsqueda</h1>
</header>
<section aria-labelledby="teoria">
<h2 id="teoria">Antes de empezar</h2>
<p>Una función puede devolver el resultado de <a href="https://www.w3schools.com/jsref/jsref_includes_array.asp" target="_blank" rel="noopener noreferrer">includes</a> directamente mediante <em>return</em>.</p>
<pre><code>function hayTalla(tallas, tallaBuscada) {
return tallas.includes(tallaBuscada);
}
console.log(hayTalla(["S", "M"], "M")); // true</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>Completa <em>isFishHere</em>. Usa includes para devolver <em>true</em> si <em>fishToFind</em> está en <em>fishes</em> y <em>false</em> en caso contrario.</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
true
true
true
false
true
false
false</pre>
</details>
</main>
<script>
function isFishHere(fishes, fishToFind) {
// Completa la función.
}
// Conjunto de pruebas para isFishHere
console.log(isFishHere(["Nemo", "Dory", "Marlin", "Bruce"], "Nemo")); // true
console.log(isFishHere(["Nemo", "Dory", "Marlin", "Bruce"], "Dory")); // true
console.log(isFishHere(["Nemo", "Dory", "Marlin", "Bruce"], "Marlin")); // true
console.log(isFishHere(["Nemo", "Dory", "Marlin", "Bruce"], "Bruce")); // true
console.log(isFishHere(["Nemo", "Dory", "Marlin", "Bruce"], "Flounder")); // false
console.log(isFishHere(["Flounder", "Sebastian", "Scuttle"], "Flounder")); // true
console.log(isFishHere(["Flounder", "Sebastian", "Scuttle"], "Dory")); // false
console.log(isFishHere(["Nemo", "Dory", "Marlin"], "nemo")); // false
</script>
</body>
</html>