Advertisement
Michal_Pilarski

zadania z funkcji w js

Jan 27th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. zad.1
  2. <!DOCTYPE html>
  3. <html lang="pl">
  4. <head>
  5. <meta charset="utf-8" />
  6. <script type="text/javascript">
  7. let a = parseInt(prompt("Podaj liczbe"));
  8.  
  9. function wartosc_bezwzgledna(a)
  10. {
  11.     if(a>=0)
  12.     document.write(a);
  13.     else
  14.     document.write(a*-1);
  15. }
  16.  
  17. wartosc_bezwzgledna(a);
  18.  
  19. </script>
  20. </head>
  21. <body>
  22. </body>
  23. </html>
  24.  
  25. zad.2
  26. <!DOCTYPE html>
  27. <html lang="pl">
  28. <head>
  29. <meta charset="utf-8" />
  30. <script type="text/javascript">
  31. let a = parseInt(prompt("Podaj liczbe"));
  32.  
  33. function czy_parzysta(a)
  34. {
  35.     if(a%2==0)
  36.     document.write(true);
  37.     else
  38.     document.write(false);
  39. }
  40.  
  41. czy_parzysta(a);
  42.  
  43. </script>
  44. </head>
  45. <body>
  46. </body>
  47. </html>
  48.  
  49. zad.3
  50. <!DOCTYPE html>
  51. <html lang="pl">
  52. <head>
  53. <meta charset="utf-8" />
  54. <script type="text/javascript">
  55. let a = prompt("Podaj znak");
  56. let b = parseInt(prompt("Podaj dlugosc"));
  57.  
  58. function szlaczek(a,b)
  59. {
  60.     for(let i=1; i<=b; i++)
  61.     {
  62.         document.write(a);
  63.     }
  64. }
  65.  
  66. szlaczek(a,b);
  67.  
  68. </script>
  69. </head>
  70. <body>
  71. </body>
  72. </html>
  73.  
  74. zad.5
  75. <!DOCTYPE html>
  76. <html lang="pl">
  77. <head>
  78. <meta charset="utf-8" />
  79. <script type="text/javascript">
  80.  
  81. let a = parseInt(prompt("Podaj bok trojkata"));
  82. let b = parseInt(prompt("Podaj bok trojkata"));
  83. let c = parseInt(prompt("Podaj bok trojkata"));
  84.  
  85. function obwod_trojkata(a,b,c)
  86. {
  87.     document.write(a+b+c);
  88. }
  89.  
  90. obwod_trojkata(a,b,c);
  91.  
  92. </script>
  93. </head>
  94. <body>
  95. </body>
  96. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement