He realizado el algortimo de ordenamiento por selección, pero no consigo que el algoritmo recorra todo el array. ¿Podrían ayudarme a encontrar el fallo en mi código?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h2 id="alg"></h2>
</body>
<script>
function num(arr) {
var leng = arr.length,
i, x;
for( i = 0; i < leng; i++) {
for( x = i + 1; x < leng; x++) {
if (arr[i] > arr[x]) {
a(arr, i, x);
}
}
}
}
function a(arr, f, s) {
var temp = arr[f];
arr[f] = arr[s];
arr[s] = temp;
}
document.getElementById("alg").innerHTML = num([8, 5, 2, 6, 9, 3, 1, 4, 0, 7]);
</script>
</html>
num(arr)
y con que valor? – Mikel Ferreiro el 8 abr. 19 a las 7:19