0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<p>Great job! We told JavaScript to show the password if the user ticked the checkbox. And if the checkbox is left unticked, then the password must be hidden. However, this is not what happens right now: if we check the box once, then password will always remain visible. How can we fix this?</p>
1
<p>Great job! We told JavaScript to show the password if the user ticked the checkbox. And if the checkbox is left unticked, then the password must be hidden. However, this is not what happens right now: if we check the box once, then password will always remain visible. How can we fix this?</p>
2
<p>Add a conditional statement to the event handler and check if the checkbox is checked. If it is, then the password field must be a regular text field. If it is not checked, then the field must return the password type. To check the state of the checkbox, use the checked property.</p>
2
<p>Add a conditional statement to the event handler and check if the checkbox is checked. If it is, then the password field must be a regular text field. If it is not checked, then the field must return the password type. To check the state of the checkbox, use the checked property.</p>
3
<p>This property has the boolean value true if the checkbox is checked and false if it is unchecked.</p>
3
<p>This property has the boolean value true if the checkbox is checked and false if it is unchecked.</p>
4
// Check whether the checkbox has been checked if (showPassword.checked) { // Show password } else { // Hide password }<p>Add a conditional statement to the event handler and make sure that the password is shown if the box is ticked and hidden if it is unticked.</p>
4
// Check whether the checkbox has been checked if (showPassword.checked) { // Show password } else { // Hide password }<p>Add a conditional statement to the event handler and make sure that the password is shown if the box is ticked and hidden if it is unticked.</p>