if else dosn't work

wanna some help in js This is a login page, there is an option to show or hide password, when I click on the icon I selected it shows the password and work perfectly fine, the issue here when I click back on icon, it doesn't make any action as I ordered, how to fix that?
No description
3 Replies
Chooβ™šπ•‚π•šπ•Ÿπ•˜
You need a double or triple equal for comparison. Your if condition is actually assigning and not testing equality.
if (input.type === 'password'){}
if (input.type === 'password'){}
What is happening in line 8 is input.type gets assigned to be "password" every time but assignments return the value being assigned, so the expression evaluates to the string "password" and a string is only falsy if it's empty, so "password" is truthy and line 10 gets executed. The end result is input.text will always be "text" after the first run.
ziad_hatem2011
ziad_hatem2011β€’16mo ago
You should use in if identical operator if (input.type === "password" )
3moor_m
3moor_mOPβ€’16mo ago
Thanks brothers I was really stuck!
Want results from more Discord servers?
Add your server