Lab 25 Reflection
Lab 25 was about creating a script that would log what key the user pressed in the console as well has add an image to the webpage when the user typed in the secret message. Though I didn't have to, I set up an <h2> tag in my HTML with a special id I would use to display what character the user typed on the webpage as well. Then, in the JS, I created and empty array, var pressed, that would be used later on to store all the keys the user pressed as well as see if the user typed in the secret code and another variable, var secret, that stored the string that was the secret code. Using .addEventListener to add a keyup function to the window, I made the console and my <h2> tag from earlier display the key that was pressed by using e.key in a console.log() function and a DOM function that modified the innerHTML of my <h2>. The keys that were pressed were added to the array, pressed, and finally, via an if statement, the function checked an amount of characters equal to the length of the secret code last added to the pressed array. If the sequence of these characters matched the secret code, a function called cornify(), linked to an online JS library, was called adding an image to the screen.
These skills are important to a web designer because they are the base steps in creating a site where they user has an account. Accounts require passwords to be logged into and programing events to fire off when a secret code is typed is akin to allowing a user access to their account when they typed the correct password. Much more is involved when actually allowing users to have accounts, such as SSL certificates, but these are the first steps.
These skills are important to a web designer because they are the base steps in creating a site where they user has an account. Accounts require passwords to be logged into and programing events to fire off when a secret code is typed is akin to allowing a user access to their account when they typed the correct password. Much more is involved when actually allowing users to have accounts, such as SSL certificates, but these are the first steps.
Comments
Post a Comment