I'm looking to update a text block with the value of a button, but I'm not sure how to get the value from the function for use.
var allButtons = document.querySelectorAll('div[class^=digits]');
for (var i = 0; i < allButtons.length; i++) {
allButtons[i].addEventListener('click', function current() {
let current = this.innerText;
console.log(current);
return current;
});
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
<title>Document</title>
</head>
<body>
<div class='container'>
<div class='calculator'>
<div class='window'>
<input type="text" class="window" name="display" id="display" id='window'>
</div>
<div class='digits'><button>7</button></div>
<div class='digits'><button>8</button></div>
<div class='digits'><button>9</button></div>
<div class='digits'><button>4</button></div>
<div class='digits'><button>5</button></div>
<div class='digits'><button>6</button></div>
<div class='digits'><button>1</button></div>
<div class='digits'><button>2</button></div>
<div class='digits'><button>3</button></div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>