So I believe the title says it all. Does anybody know why? Also, the decimal point doesnt visibly appear, but the code acts like it is there.
PS: Please don't try and fix my code in a way that doesn't help me fix this, I find it annoying
let n = [
1, 2, 3, 4, 5
]
let i = 0
let it = 0
let l = 1000 ^ 100
let p = 0
let sort = true
let f = 0
let g = n.length
let h = 0
document.getElementById('button').addEventListener("click", function() {
stuff()
})
function stuff() {
if (n[0] <= n[1] && n[1] <= n[2] && n[2] <= n[3] && n[3] <= n[4]) {
n[0] = document.getElementById("a").value
n[1] = document.getElementById("b").value
n[2] = document.getElementById("c").value
n[3] = document.getElementById("d").value
n[4] = document.getElementById("e").value
it = 0
i = 0
l = 1000 ^ 100
p = 0
sort = true
f = 0
g = 0
h = 0
}
console.log("in function 1")
lowestSort(n)
}
function lowestSort(n) {
console.log("in function 2")
sort = true
while (g <= n.length && sort == true) {
console.log("in while loop")
if (n[i] > n[g] && g >= f) {
[n[i], n[g]] = [n[g], n[i]]
console.log(g)
sort = false
} else {
f = i + 1
console.log("f =", f)
}
g += 1
}
g = 0
i += 1
it += 1
if (i == 4) {
i = 0
}
document.getElementById("f").innerHTML = n
document.getElementById("g").innerHTML = it
}
<h1>superSort Algorithm</h1><a href=".\dubble.html">(Psst: Click me for dubble sort!)</a><br><a href=".\bubble.html">(Psst: Click me for bubble sort!)</a>
<p>Enter your number. superSort checks to see if any number is less then the one its on, and if so switches them, and if not it freezes it.</p><br>
<title>superSort</title>
<input type=number id="a"></input>
<br>
<input type=number id="b"></input>
<br>
<input type=number id="c"></input>
<br>
<input type=number id="d"></input>
<br>
<input type=number id="e"></input>
<br><br><button id="button">Press me to run 1 itteration</button>
<p>Output: <span id="f">N/A</span></p>
<p>Iterations: <span id="g">N/A</span></p>
Sorry that it is a bit long, I don't want to leave it at just the JS and make you do the work to put make it work. Thank you in advance. I have tried seeing if I have the same issues in some similar files and I do, so it might be in the stuff() function.