I have a problem when i try to display new prompt, i use loop but it will display both my prompt. Here is my code and i really need help
<body>
<p id="age" style="font-weight: bold"></p>
<button onclick=" notify()">Try it</button>
<script>
function notify(){
var age = document.getElementById("age").value;
var age = prompt("Enter Your birth year:");// This is the first prompt
const year = new Date().getFullYear();
if (age != null) {
document.getElementById("age").innerHTML =
"Your " + age + " is so beautiful"; // If user enter birth year < current year will display this
}
do {
age = prompt("Re-enter your birth year:"); // Ortherwise, this will display and they need to enter until birth year < current year
} while (age > year && age != null);
var tuoi = year - age;// This is just calculate user'age, for example if the user enter 2000 will display user'age is 22
document.getElementById("age").innerHTML =
"Tuổi " + tuoi + " này đẹp đó";
}
</script>
</body>