Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. const bool = true;
  2. const number = 12;
  3. const string = "hello world!";
  4. const array = [1, 22, 33];
  5. //const array2 = array;
  6. //array.push(4);
  7. const object = { 0: 1, 1: 2, c: 3 };
  8.  
  9. //console.log(object.c);
  10.  
  11. //const answer = number == 12 ? "yes" : "no";
  12. //number == 12 ? console.log("yes") : console.log("no");
  13.  
  14. /*let answer2 = "no";
  15. if (number == 12) {
  16. answer2 = "yes";
  17. }*/
  18.  
  19. /*while (true) {
  20. console.log(number);
  21. }*/
  22.  
  23. //let counter = 1;
  24. /*while (true) {
  25. console.log(counter);
  26. counter = counter + 1;
  27. //counter++;
  28. //++counter;
  29. }*/
  30.  
  31. /*const start = performance.now();
  32.  
  33. while (counter <= 100) {
  34. console.log(counter);
  35. counter++;
  36. }
  37.  
  38. const end = performance.now();
  39. console.log(end - start);
  40. */
  41.  
  42. //wrażliwy na wielkość liter
  43.  
  44. /* for (let i = 1; i <= 100; i++) {
  45. console.log(i);
  46. } */
  47.  
  48. /*for (let i = 0; i < array.length; i++) {
  49. console.log(i);
  50. }*/
  51.  
  52. /*for (let i = 0; i < array.length; i++) {
  53. console.log(i, array[i]);
  54. }*/
  55. /*
  56. array.forEach(function(value, index) {
  57. console.log(index, value);
  58. }); //funkcja anonimowa
  59. //nic nie zwraca jak VOID
  60. */
  61.  
  62. /*
  63. array.map(function(value, index) {
  64. console.log(index, value);
  65. }); //mapowanie wartości, towrzy nową tablicę z taką samą ilością ale z przetworzonymi elementami
  66. */
  67. /*
  68. function add(a, b) {
  69. return a + b;
  70. }
  71.  
  72. const add2 = function(a, b) {
  73. return a + b;
  74. };
  75.  
  76. const add3 = (a, b) => {
  77. return a + b;
  78. };
  79.  
  80. const add4 = (a, b) => a + b;
  81.  
  82. const add5 = a => a + 5;
  83.  
  84. console.log(add, add2, add3, add4, add5);
  85. const newArray = array.map(add5);
  86. const newArray2 = array.map(value => value + 5);
  87. console.log(newArray, newArray2);
  88. */
  89.  
  90. /*
  91. const expr = "Oranges";
  92. switch (expr) {
  93. case "Oranges":
  94. console.log("Oranges are $0.59 a pound.");
  95. break;
  96. case "Mangoes":
  97. case "Papayas":
  98. console.log("Mangoes and papayas are $2.79 a pound.");
  99. break;
  100. default:
  101. console.log("Sorry, we are out of " + expr + ".");
  102. }
  103. */
  104. /*
  105. const value = 2;
  106. const translate = value => {
  107. switch (value) {
  108. case 1:
  109. return "one";
  110. case 2:
  111. return "two";
  112. case 3:
  113. return "three";
  114. case 4:
  115. return "four";
  116. case 5:
  117. return "five";
  118. case 6:
  119. return "six";
  120. case 7:
  121. return "seven";
  122. case 8:
  123. return "eight";
  124. case 9:
  125. return "nine";
  126. default:
  127. return "Sorry, we don't have " + value + " in our numbers.";
  128. }
  129. };
  130. console.log(translate(6));*/
  131.  
  132. const random = Math.random();
  133. console.log(random);
  134. console.log(random * 10);
  135. console.log(Math.floor(random * 10));
  136.  
  137. const getRandomInt = () => Math.floor(Math.random() * 10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement