Advertisement
MilenaK

Labs-01 [ IP ]

Mar 30th, 2020
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-------------------------------------------
  2. // LAB-01 ИНТЕРНЕТ ПРОГРАМИРАЊЕ
  3. //-------------------------------------------
  4.  
  5. // Proveruva dali e 3 cifreniot broj palindrom
  6. num = prompt("Vnesi 3 cifren broj: ");
  7.  
  8. while( num.length != 3 || isNaN(num) ) 
  9.     num = prompt("Vnesi 3 cifren broj: ");
  10.  
  11. if( Math.floor(num / 100) == num % 10 )
  12.     alert("Nice Job.");
  13.  
  14. //-------------------------------------------
  15.  
  16. // Prikaz na tel. broj i od koj operator e
  17.  
  18. phone = prompt("Vnesi telefonski broj: ");
  19. while(phone.length != 8)
  20.     phone = prompt("Vnesi telefonski broj: ");
  21.  
  22.  
  23. phone = "0" + phone.slice(0,2) + "/" + phone.slice(2, 5) + "-" + phone.slice(5);
  24. op = phone.slice(1,3);
  25. operator = "";
  26.  
  27. switch(parseInt(op)) {
  28.     case 70:
  29.     case 71:
  30.     case 72:
  31.         operator = " T-mobile";
  32.         break;
  33.     case 75:
  34.     case 76:
  35.         operator = " One";
  36.         break;
  37.     case 77:
  38.     case 78:
  39.         operator = " Vip";
  40.         break;
  41. }
  42.  
  43. phone = phone + operator;
  44. alert("Your phone number is: " + phone);
  45.  
  46. // -------------------------------------------
  47.  
  48. // Find max len word in string
  49.  
  50. string = prompt("Your string: ");
  51.  
  52. string = string.split(" ");
  53. max = "";
  54.  
  55. for( word of string )
  56.     if (word.length > max.length)
  57.         max = word;
  58.  
  59.  
  60. alert(max);
  61.  
  62. // -------------------------------------------
  63.  
  64. // Find the sign of the product of given numbers
  65.  
  66. numbers = prompt("Numbers: ");
  67.  
  68. numbers = numbers.split(",");
  69.  
  70. sign = 1;
  71. for(num of numbers){
  72.     if(num < 1)
  73.         sign *= -1;
  74. }
  75.  
  76. if(-1 == sign)
  77.     alert("-");
  78. else
  79.     alert("+");
  80.  
  81. // -------------------------------------------
  82.  
  83. // Paren - neparen broj.
  84.  
  85. for(i = 0; i < 31; i++) {
  86.  
  87.     if(i % 2 == 0)
  88.         document.write("<p>" + i + " e paren broj.</p>");
  89.     else
  90.         document.write("<p>" + i + " e neparen broj.</p>");
  91. }
  92.  
  93. // -------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement