0% found this document useful (0 votes)
7 views3 pages

Array Code

The document is an HTML page that implements a user interface for generating and managing a list of values using JavaScript. It includes buttons for generating values, selecting random values, and displaying them in ascending or descending order. The page uses Bootstrap for styling and jQuery for functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Array Code

The document is an HTML page that implements a user interface for generating and managing a list of values using JavaScript. It includes buttons for generating values, selecting random values, and displaying them in ascending or descending order. The page uses Bootstrap for styling and jQuery for functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

<!

DOCTYPE html>
<html lang="es">

<head>
<meta charset="utf-8" />
<link rel="stylesheet"
href="[Link]
s" integrity="sha384-
zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn"
crossorigin="anonymous">
<script
src="[Link]
integrity="sha384-
DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script
src="[Link]
[Link]" integrity="sha384-
fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF"
crossorigin="anonymous"></script>
<script src="[Link]
crossorigin="anonymous"></script>
<script src="//[Link]/npm/sweetalert2@11"></script>
<script src="[Link]
<title>Fractal</title>
</head>

<body>
<div class="container">
<div class="row" style="margin: 10px;">
<div class="col-8">
<h5>Practica de la unidad <i class="fa-solid fa-
hand"></i></h5>
<input style="margin-bottom: 10px;" type="text" class="form-
control" name="posiciones" id="posiciones" placeholder="Cantidad de
Posiciones" value="" />
<button type="button" class="btn btn-primary"
onclick="generar();">Generar</button>
<button type="button" class="btn btn-secondary"
onclick="generaraleatorio();">Aleatorio</button>
<button type="button" class="btn btn-success"
onclick="ascendente();">Ascendente</button>
<button type="button" class="btn btn-danger"
onclick="descendente();">Descendente</button>
<button type="button" class="btn btn-warning"
onclick="dosaleatorios();">Generar 2 aleatorios</button>
</div>
</div>
</div>
</body>
<script>
let valores = [];

function generar() {

var base = $("#posiciones").val();


for (var i = 1; i <= base; i++) {
var nombre = prompt("Ingresa un valor: ");
[Link](nombre);
}
}

function generaraleatorio() {
var máximo = [Link] - 1;
var mínimo = 0;
var aleatorio = [Link]([Link]() * ((máximo + 1) - mínimo) +
mínimo);
alert("Aleatorio: "+valores[aleatorio]);
}

function dosaleatorios() {
var máximo = [Link] - 1;
var mínimo = 0;
var aleatorio = [Link]([Link]() * ((máximo + 1) - mínimo) +
mínimo);
var aleatorio2 = [Link]([Link]() * ((máximo + 1) - mínimo)
+ mínimo);
alert("Aleatorio 1: " + valores[aleatorio] + "\nAleatorio 2: " +
valores[aleatorio2]);
}

function ascendente() {
for (var i = 0; i <= [Link] - 1; i++) {
alert("Valor " + i + ": " + valores[i]);
}
}

function descendente() {
for (var i = [Link] - 1; i >= 0; i--) {
alert("Valor " + i + ": " + valores[i]);
}

}
</script>

</html>

You might also like