Skip to content

Commit

Permalink
Simplify sort fn
Browse files Browse the repository at this point in the history
  • Loading branch information
aricooperdavis committed Nov 2, 2024
1 parent 33be25e commit 5362d67
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ goButton.onclick = function calculate() {
// Get values of inputs
let ropes = [];
for (let el of document.getElementsByClassName('rope')) {
ropes.push(el.firstChild.value);
ropes.push(parseInt(el.firstChild.value));
};
ropes = ropes.map(el => parseInt(el)).filter(el => el).sort((a, b) => a < b);
ropes = ropes.sort();
let join_ropes = document.getElementById('join').checked;

// Reset output
Expand Down

0 comments on commit 5362d67

Please sign in to comment.