Skip to content

Commit

Permalink
use querySelector for things that want just one result (#1)
Browse files Browse the repository at this point in the history
That way you don't have to explicitly ask for the first result.
  • Loading branch information
Haroenv authored and mischah committed Sep 25, 2016
1 parent 1cd59d2 commit 20877e1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ document.addEventListener('DOMContentLoaded', function () {
var checkLength = function (output) {
var length = String(output).length;
if (length <= 8) {
document.querySelectorAll('output')[0].classList.remove('small-text');
document.querySelectorAll('output')[0].classList.remove('extra-small-text');
document.querySelector('output').classList.remove('small-text');
document.querySelector('output').classList.remove('extra-small-text');
}
if (length > 8) {
document.querySelectorAll('output')[0].classList.add('small-text');
document.querySelector('output').classList.add('small-text');
}
if (length > 17) {
document.querySelectorAll('output')[0].classList.remove('small-text')
document.querySelectorAll('output')[0].classList.add('extra-small-text');
document.querySelector('output').classList.remove('small-text')
document.querySelector('output').classList.add('extra-small-text');
}
if (length > 29) {
clearOutput();
Expand All @@ -54,12 +54,12 @@ document.addEventListener('DOMContentLoaded', function () {
};

var renderOutput = function (output) {
document.querySelectorAll('output')[0].textContent = output;
document.querySelector('output').textContent = output;
checkLength(output);
};

var getInput = function () {
return document.querySelectorAll('output')[0].textContent;
return document.querySelector('output').textContent;
}

var addToOutput = function (value) {
Expand Down

0 comments on commit 20877e1

Please sign in to comment.