Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created December 28, 2019 00:34
Show Gist options
  • Save Fhernd/658e76f5ffc72dec4adf4593f194cdf7 to your computer and use it in GitHub Desktop.
Save Fhernd/658e76f5ffc72dec4adf4593f194cdf7 to your computer and use it in GitHub Desktop.
// Ejercicio 39: Uso del método $.map() para crear una lista de cadenas enumeradas.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>jQuery - Ejercicios</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<h1>jQuery - Ejercicio 39</h1>
<h3>Lenguajes de programación</h3>
<p id="lenguajes"></p>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/ex039-script.js"></script>
</body>
</html>
// Ejercicio 39: Uso del método $.map() para crear una lista de cadenas enumeradas.
$(document).ready(() => {
let lenguajes = ['JavaScript', 'Python', 'C++', 'Java', 'PHP', 'C'];
// 1. JavaScript
// 2. Python
// 3. C++
// ...
lenguajes = $.map(lenguajes, (valor, indice) => {
return `${indice + 1}. ${valor}`;
});
$('#lenguajes').html(lenguajes.join('<br/>'));
});
.highlight{
font-style: italic;
background-color: #ffff00;
}
.features{
font-style: italic;
background-color: crimson;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment