1- // get elements from page
1+ // get and create elements from page
22const restoreBtn = document . getElementById ( "restoreBtn" ) ;
33const authInput = document . getElementById ( "authcode" ) ;
44const keyInput = document . getElementById ( "name" ) ;
55const messageBox = document . createElement ( "p" ) ;
66document . querySelector ( "main" ) . appendChild ( messageBox ) ;
77
88// fake data for testing
9- const validKeys = [ "alpha123 " , "bravo456 " , "charlie789" ] ;
10- const expectedAuthCode = "unlock" ;
9+ const validKeys = [ "justin123 " , "kid456 " , "charlie789" ] ; // decrypt id
10+ const expectedAuthCode = "unlock" ; // auth code
1111
12- // check inputs and show result
12+ // verification function
1313function simulateRestore ( ) {
1414 const key = keyInput . value . trim ( ) ;
1515 const auth = authInput . value . trim ( ) ;
16-
17- // compare values
16+ // main check logic compare values
1817 if ( validKeys . includes ( key ) && auth === expectedAuthCode ) {
1918 messageBox . textContent = "✅ data successfully restored" ;
2019 messageBox . style . color = "limegreen" ;
@@ -27,5 +26,5 @@ function simulateRestore() {
2726// run when button clicked
2827restoreBtn . addEventListener ( "click" , ( event ) => {
2928 event . preventDefault ( ) ; // stop form reload
30- simulateRestore ( ) ;
29+ simulateRestore ( ) ; // call function
3130} ) ;
0 commit comments