Skip to content

Commit

Permalink
Refactor formatDisplay for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
zalbright90 committed Jul 16, 2024
1 parent 67c4c64 commit 73ff692
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ document.addEventListener('DOMContentLoaded', function() {
displayValue = "";
}
displayValue += value;
if (displayValue.length > MAX_DISPLAY_LENGTH) {
displayValue = parseFloat(displayValue).toExponential(MAX_DISPLAY_LENGTH - 7);
}
displayValue = formatDisplay(displayValue);
displayOutput.textContent = displayValue;
}

function formatDisplay(value) {
if (value.length > MAX_DISPLAY_LENGTH) {
return parseFloat(displayValue).toExponential(MAX_DISPLAY_LENGTH - 7);
}
return value;
}

function resetDisplay() {
displayValue = "";
calculationJustCompleted = false;
Expand Down

0 comments on commit 73ff692

Please sign in to comment.