joelnazarene

Untitled

Mar 4th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.64 KB | None | 0 0
  1. <HTML>
  2. <head><title> the title name goes here</title>
  3. </head>
  4. <body>
  5. <h1> this is a heading </h1>
  6. <p id="demo"> </p>
  7. <script>
  8. var cars = ["A", "B", "C","D","A"];
  9.  
  10.  
  11. var c=[0,0,0,0,0];
  12. var count=[0,0,0,0,0];
  13. for(var i =0 ; i<5 ; i <i++){
  14.  
  15. for(var j =0 ; j< 5;j++){
  16.  
  17. if(j<i && cars[i]==cars[j]){
  18. count[j]=0;
  19. }
  20. if(cars[i]== cars[j]){
  21. c[i]++;
  22. }
  23.  
  24. }
  25. }
  26.  
  27. document.getElementById("demo").innerHTML = c;
  28.  
  29. var maxi=c[0]
  30. var maxipos=0;
  31. var maximum=0;
  32. for (var i=1;i<5;i++)
  33. {
  34. if(c[i]>maxi){
  35.  
  36.   maxi=c[i];
  37.   maxipos=i;
  38. }
  39.  maximum=cars[maxipos];
  40. }
  41.  
  42. document.write("the frequent element is   " +maximum);
  43. </script>
  44. </body>
  45. </HTML>
Add Comment
Please, Sign In to add comment