StefiIOE

zadaca 1 prv termin juni ipks

Aug 15th, 2020 (edited)
2,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Title</title>
  6. </head>
  7. <script>
  8.     function pomestiLevo() {
  9.         var cifra = document.getElementById('pole').value;
  10.         cifra=cifra.split('');
  11.  
  12.         for(var i =cifra.length ; i >=0 ; --i){
  13.  
  14.             var tmp=cifra[cifra.length-1];
  15.             cifra[cifra.length-1]=cifra[i];
  16.             cifra[i]=tmp;
  17.         }
  18.  
  19.         cifra=cifra.join('');
  20.         document.getElementById('pole').value=cifra;
  21.     }
  22.     function pomestiDesno() {
  23.         var cifra = document.getElementById('pole').value;
  24.         cifra=cifra.split('');
  25.         for(var i = 0 ; i < cifra.length ; i ++) {
  26.             var tmp = cifra[i];
  27.             cifra[i] = cifra[cifra.length-1];
  28.             cifra[cifra.length-1] = tmp;
  29.         }
  30.  
  31.         cifra=cifra.join('');
  32.         document.getElementById('pole').value=cifra;
  33.     }
  34.     function Prevrti() {
  35.         var cifra = document.getElementById('pole').value;
  36.         cifra=cifra.split('');
  37.         cifra.reverse();
  38.         cifra=cifra.join('');
  39.         document.getElementById('pole').value=cifra;
  40.     }
  41.     function Proveri() {
  42.         var cifra = document.getElementById('pole').value;
  43.         cifra=cifra.split('');
  44.         var flag = Boolean(true);
  45.         for(var i = 0 ; i < cifra.length; i ++){
  46.             if(cifra[i]%2==0 && cifra[i+1] %2== 0 )
  47.             {
  48.                 flag = false;
  49.             }
  50.         }
  51.         if(flag == false){
  52.             document.write("Brojot e perfekten");
  53.         }
  54.  
  55.     }
  56.     function Zacuvaj() {
  57.  
  58.  
  59.         var cifra = document.getElementById('pole').value;
  60.         var lista = document.getElementById('lista');
  61.         var li=document.createElement('li');
  62.  
  63.         var text=document.createTextNode( 'izbrishan broj : ' +cifra );
  64.         li.appendChild(text);
  65.         lista.appendChild(li);
  66. document.getElementById('pole').value="";
  67.  
  68.     }
  69. </script>
  70.  
  71.  
  72.  
  73.  
  74. <body>
  75.  
  76. <input type="text" id="pole">
  77. <button onclick="pomestiLevo()"><</button>
  78. <button onclick="pomestiDesno()">></button>
  79. <button onclick="Prevrti()">Flip</button>
  80. <button onclick="Proveri()">Check</button>
  81. <button onclick="Zacuvaj()">Store</button>
  82. <ul id="lista">
  83.  
  84. </ul>
  85.  
  86. </body>
  87. </html>
Add Comment
Please, Sign In to add comment