0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<p>We made the bar grow together with the password length. Great job! Now we need to assign it the right color. If the password is short, the bar should be red, if it is of average length, then it should be yellow, and if the password is long, then it should be green. To do this, we need a conditional statement in which we will compare the password.value.length password length with various numbers. As a result, this entry can be very long.</p>
1
<p>We made the bar grow together with the password length. Great job! Now we need to assign it the right color. If the password is short, the bar should be red, if it is of average length, then it should be yellow, and if the password is long, then it should be green. To do this, we need a conditional statement in which we will compare the password.value.length password length with various numbers. As a result, this entry can be very long.</p>
2
<p>Let’s make it more convenient in advance: write the password length to a separate variable and use it.</p>
2
<p>Let’s make it more convenient in advance: write the password length to a separate variable and use it.</p>
3
let passLength = password.value.length;<p>The password length changes with each character that is entered. In order for the passLength variable to always have the current value, it needs to be assigned inside the oninput event handler.</p>
3
let passLength = password.value.length;<p>The password length changes with each character that is entered. In order for the passLength variable to always have the current value, it needs to be assigned inside the oninput event handler.</p>
4
<p>Declare the passLength variable and use it in the instructions where we need the password length. Check that nothing is broken.</p>
4
<p>Declare the passLength variable and use it in the instructions where we need the password length. Check that nothing is broken.</p>