Been trying to figure out a way to remove the result of my flex box result whenever I press the Reset
button. Tried everything I could think of and pretty new to JavaScript so any help and explanations would be really appreciated. I don't know if I'm doing something wrong with my JavaScript file or not calling it properly.
let button = document.getElementById('action');
button.addEventListener('click', function() {
let birthYear = prompt("what year were you born...Good friend?");
let ageInDays = (2020 - birthYear) * 365;
let h1 = document.createElement('h1');
let textAnswer = document.createTextNode('You are ' + ageInDays + 'days old');
h1.setAttribute('id', 'ageInDays');
h1.appendChild(textAnswer);
document.getElementById('flex-box-result').appendChild(h1);
console.log(ageInDays);
});
const button2 = document.getElementById('Reset');
button.addEventListener('click', function() {
document.getElementById('flex-box-result').remove
})
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"></link>
<div class="container-1">
<h2>Challenge 1: How Many Days You Have Lived</h2>
<div class="flex-box-container-1">
<div>
<button class="btn btn-primary" id="action">Click Here></button>
</div>
<div>
<button class="btn btn-danger" id="Reset">Reset</button>
</div>
<div class="flex-box-container-1">
<div id="flex-box-result"></div>
</div>
</div>
</div>