Advertisement
Morlom

Zadanie 3 - funkcje

Jan 25th, 2022
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.     var x, y;
  3.     var a = '1';
  4.     var b = '9';
  5.     function PODZIELNOSC() {
  6.         x = prompt("Podaj ilocyfrowe liczby Cię interesują");
  7.         y = prompt("Podaj przez co mają być podzielne");
  8.  
  9.         if (x == 1) {
  10.             document.write("Twoje liczby to: ");
  11.             for (x = 1; x <=9; x++){
  12.                 if (x%y == 0) {
  13.                     document.write(x+ " ");
  14.                 }
  15.             }
  16.         }
  17.         else if (x <= 0 || y <= 0) {
  18.             document.write("Co ty próbujesz zrobić?")
  19.         }
  20.         else {
  21.             document.write("Twoje liczby to: ");
  22.             for (let i = 1; i < x; i++) {
  23.                 a = a.concat('0');
  24.                 b = b.concat('9');
  25.             }
  26.             a = parseInt(a);
  27.             b = parseInt(b);
  28.             for (let j = a; j <= b; j++) {
  29.                 if (j%y == 0) {
  30.                     document.write(j+ " ");
  31.                 }
  32.             }
  33.         }
  34.     }
  35.     PODZIELNOSC();
  36. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement