The window.confirm function returns the result of the confirmation (true or false), but your code isn't capturing that result. You can capture it in a variable:
let confirmed = confirm("Do you want to continue?");
Also, take a look at what you're doing here:
while(confirm !== true)
We already know that confirm is a function. And we know that you append parentheses when you want to call a function. So this isn't calling the function, it's just referencing it. And the function itself will never equal true, so this loop is infinite (and meaningless).
Additionally, this doesn't do anything:
confirm;
Again, we know what confirm is already and we know how to call a function already. So this doesn't call the function, it's just a reference to the function. Sitting there. Not doing anything.
Instead, the loop can check the variable:
while (confirmed) {
And in the loop you can repeat the call to confirm from before the loop:
confirmed = confirm("Do you want to continue?");
Which leaves us with:
let confirmed = confirm("Do you want to continue?");
alert("Hello!");
while (confirmed) {
confirmed = confirm("Do you want to continue?");
}
There's a lot of repetition here. This can be simplified. This also doesn't do what the assignment asks, because the alert operation isn't being repeated. Let's fix that logic before simplifying:
let confirmed = confirm("Do you want to continue?");
while (confirmed) {
alert("Hello!");
confirmed = confirm("Do you want to continue?");
}
We can remove the duplicate confirm operation by simply swapping the operations in the loop, which would make the one outside the loop superfluous:
let confirmed = true;
while (confirmed) {
confirmed = confirm("Do you want to continue?");
alert("Hello!");
}
There's also a lot of repetition of this confirmed variable, which we don't really need. The condition being checked by the loop doesn't need to be a variable, it just needs to evaluate to a boolean value. And the confirm function already returns that. So just use it directly:
while (confirm("Do you want to continue?")) {
alert("Hello!");
}