Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. var repeticion = setInterval(function aleatorio() {
  2.  
  3. var rand = myArray[Math.floor(Math.random() * myArray.length)];
  4.  
  5.  
  6. if (rand == 200) {
  7. console.log("HTTP 200! Encontrado!");
  8. encontrado = true;
  9.  
  10. } else if (rand == 500) {
  11. console.log("HTTP 500! Error interno del servidor");
  12. encontrado = true;
  13.  
  14. } else if (rand == 204) {
  15. console.log("HTTP 204!");
  16.  
  17. } else if (rand == 404) {
  18. console.log("HTTP 404!");
  19. }
  20.  
  21. cont++;
  22.  
  23. if (encontrado === true) {
  24. stopFunction();
  25. }
  26.  
  27. }, 1000);
  28.  
  29. function stopFunction() {
  30. clearInterval(repeticion);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement