Your code is correct. I still have two remarks:
- Task 3: In the switch condition I would rather use the value
trueinstead of a variable that happens to be true there.
- Task 4: You could move
pwdResult =to the front in order to not write it twice:
This works because the ternary operator has higher precedence (priority) than the assignment and it evaluates to one or the other string.
pwdResult = pwd === 'cheese' ? 'Login successful.' : 'Password incorrect; login failed.'