daily pastebin goal
63%
SHARE
TWEET

crypt game

niro0711 Jan 24th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>cryptMe</title>
  5. </head>
  6. <body>
  7.     <center>
  8.         <h1>Crypt Game</h1><hr>
  9.  
  10.     <input type="text" placeholder="enter your text here" id="originalText"><br><br><!--make a text box whare the user enters text-->
  11.     <input type="button" value="Crypt Me!" onclick="cryptit()"/><!--make a button that when clicked crypts the text with the function-->
  12.     <div id="res"></div><!--a div to show the text after crypt-->
  13.  
  14.     </center>
  15.  
  16.     <script>
  17.         /*a fnction that take the text from the box, set a new array of string, and make a loop*/
  18.         function cryptit() {
  19.  
  20.             var myOriginal = originalText.value;
  21.             var myCrypt = "";
  22.             for(var counter = 0; counter < myOriginal.length; counter+=1) /*this loop check if the counter is less than the the value, than adds another text to counter*/
  23.             {
  24.  
  25.                 if(myOriginal[counter]=="a")
  26.                 {
  27.              myCrypt+="u"
  28.             }
  29.             else if (myOriginal[counter]=="e")
  30.                        {
  31.                            myCrypt+="o"
  32.                        }
  33.  
  34.            else if (myOriginal[counter]=="i")
  35.                        {
  36.                            myCrypt+="i"
  37.                        }
  38.            else if (myOriginal[counter]=="o")
  39.                        {
  40.                            myCrypt+="e"
  41.                        }
  42.  
  43.             else if (myOriginal[counter]=="u")
  44.                        {
  45.                            myCrypt+="a"
  46.                        }
  47.                        else {
  48.  
  49.                      myCrypt+=myOriginal[counter];
  50.  
  51.                        }
  52.                    }
  53.  
  54.                    res.innerHTML=myCrypt;/*show text in the div from the res in HTML*/
  55.  
  56.                }
  57.     </script>
  58.  
  59. </body>
  60. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top