In JavaScript, confirm() displays a dialog box with a specified message and "OK" and "Cancel" buttons, returning true if "OK" is clicked and false if "Cancel" is clicked.
Your task in this problem is to implement the handleConfirm() function. The function should
| Step No | Crucial Component | Instruction | |
|---|---|---|---|
| 0 | confirm() function | capture the return value of confirm() function in a variable. say result. | code : const result = confirm('Do you want to proceed?') |
| 1 | div#result | Select it with document.getElementById | code : const resultElement = document.getElementById('result') |
| 2 | if result is true | set the textContent of resultElement equal to OKTEXT and color to OKCOLOR | code: resultElement.textContent = OKTEXT resultElement.style.color = OKCOLOR |
| 2 | if result is false | set the textContent of resultElement equal to CANCELTEXT and color to CANCELTEXT | code: resultElement.textContent = CANCELTEXT resultElement.style.color = CANCELCOLOR |
Best of luck, developers!