Codecademy Practice

Password encryption - Part 2

Challenge: We are going to compare the password entered by the user against a list of passwords taken from our database. If the password exists in our database, we will print a success message. If not, we will print a failure message.

To practice: arrays, scope, iterators.

Example: Same as in the original password validation challenge.

Step by step instructions:

HTML

No changes.

CSS

No changes.

JS

In the previous challenge we saw how to pass functions around as an argument. Iterators are native JavaScript functions that take a function as an argument. You have to define the function that gets passed to the iterator. Another old friend of ours, addEventListener(), is also a native JavaScript function that takes another function as an argument.

const passwords = ['greenbear757', 'organicswan134', 'bluemouse519', 'heavytiger886', 'heavyladybug575'];

GIT

Work in the same project you created for the login, in a separate branch. When the branch is ready create a pull request and ping me to review.

DEBUGGING

Use console.log() as usual. Printing the value of the array in every iteration may be helpful.