Advertisement
Guest User

Generate Number without repitition

a guest
Aug 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>TaRic Kabaliwan - Q and A</title>
  8. <link rel="stylesheet" href="./bootstrap/dist/css/bootstrap.css">
  9. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
  10.  
  11. <style>
  12.  
  13. .jumbotron {
  14. text-align: center;
  15. }
  16.  
  17. .qanda {
  18. text-align: center;
  19. margin-bottom: 16px;
  20. }
  21.  
  22. .question {
  23. margin-bottom: 24px;
  24. font-size: 30px;
  25. display: none;
  26. }
  27.  
  28. </style>
  29. </head>
  30. <body>
  31. <div class="container">
  32. <div class="jumbotron display-4">TaRic Kabaliwan - Q and A</div>
  33.  
  34. <div class="qanda">
  35. <!-- content here -->
  36. <div class="question">Sample question here</div>
  37.  
  38. <div class="btn btn-primary">Click Here</div>
  39. </div>
  40.  
  41.  
  42. </div>
  43.  
  44.  
  45.  
  46. <script>
  47.  
  48. $(function() {
  49. const question = [
  50. "Sino mabilis magselos?",
  51. "Sino mabilis bumaho ang kili kili?",
  52. "Sino yung kahit nagttoothbrush na mabaho pa din ang hininga?",
  53. "Sino yung mabilis magalit?",
  54. "Sino mas mabait?"
  55.  
  56. ];
  57.  
  58.  
  59.  
  60. function questionRandom(arr) {
  61. const number = Math.floor(Math.random() * arr.length);
  62.  
  63. return arr[number];
  64. };
  65.  
  66.  
  67.  
  68.  
  69. $('.btn').on('click', () => {
  70. $('.question').show().text(questionRandom(question));
  71. })
  72.  
  73.  
  74.  
  75. var numbers = [1, 2, 3, 4];
  76.  
  77. function shuffle(o) {
  78. for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
  79. return o;
  80. };
  81.  
  82. var random = shuffle(numbers);
  83.  
  84. console.log(random);
  85.  
  86.  
  87. });
  88.  
  89. </script>
  90. </body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement