0

I want to runAgain prompt to ask Enter the color again

let runAgain = true; while(runAgain){ let color = prompt("Enter color") document.body.style.background = color runAgain = confirm("do you want to right again") } This runAgain is not working how to solve it?

28th Feb 2023, 1:29 PM
Meem Kaaf
Meem Kaaf - avatar
8 ответов
+ 4
Great, thanks. Try this in the Web code: window.onload = function () { let runAgain = true; while(runAgain){ let color = prompt("Enter color"); document.body.style.backgroundColor = color; runAgain = confirm("Do you want to write again?"); } };
1st Mar 2023, 12:27 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Save the code as public and I can attach it here for you.
28th Feb 2023, 6:24 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Thanks for your time Ausgrindtube
1st Mar 2023, 2:46 PM
Meem Kaaf
Meem Kaaf - avatar
+ 1
For starters, your while statement will be without end (I.e. infinite) because you don't have an exit condition, something that sets it to false or break.
28th Feb 2023, 1:55 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Can you attach your code from the code playground using the plus ➕️ button here please?
28th Feb 2023, 2:12 PM
Ausgrindtube
Ausgrindtube - avatar
0
Do you write it to me?
28th Feb 2023, 2:02 PM
Meem Kaaf
Meem Kaaf - avatar
0
Its not showing here
28th Feb 2023, 4:22 PM
Meem Kaaf
Meem Kaaf - avatar
0
I set it as public
1st Mar 2023, 6:59 AM
Meem Kaaf
Meem Kaaf - avatar