Last active
January 26, 2026 16:12
-
-
Save pazteddy/fa2ef581a62be72bf765b3164a953687 to your computer and use it in GitHub Desktop.
Instrucciones de tarea, listado de Catálogo y usuarios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $catalog = [ | |
| ["sku" => "LP-001", "name" => "Laptop", "price" => 1200, "stock" => 3], | |
| ["sku" => "MS-002", "name" => "Mouse", "price" => 25, "stock" => 0], | |
| ["sku" => "KB-003", "name" => "Teclado", "price" => 80, "stock" => 12], | |
| ]; | |
| $usersTask = [ | |
| ["id" => 1, "name" => "Ana", "email" => "[email protected]", "role" => "user"], | |
| ["id" => 2, "name" => "Luis", "email" => "[email protected]", "role" => "admin"], | |
| ["id" => 3, "name" => "María", "email" => "[email protected]", "role" => "editor"], | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| ============= | |
| 🏆 Tarea para funciones en arreglos para transformar y filtrar | |
| ============= | |
| */ | |
| // 1. Usar array_map para transformar una lista de usuarios. | |
| // → Cada elemento debe ser un array con las claves "id" y "label". | |
| // → "label" debe combinar el nombre y el rol con formato: "Nombre (rol)". | |
| // 2. Mostrar la lista formateada por pantalla. | |
| // → Recorrer el array resultante e imprimir cada "label" precedido por un guion (-). | |
| // → Ejemplo de salida esperada: | |
| // - Ana (admin) | |
| // - Luis (user) | |
| // - María (editor) | |
| // 3. Usar array_filter para filtrar productos disponibles. | |
| // → Incluir solo aquellos productos cuyo "stock" sea mayor a cero. | |
| // 4. Mostrar los productos disponibles. | |
| // → Por cada producto disponible, imprimir su nombre y precio en el formato: "Nombre | Precio: valor". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment