Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HTML>
- <head><title> the title name goes here</title>
- </head>
- <body>
- <h1> this is a heading </h1>
- <p id="demo"> </p>
- <script>
- var cars = ["A", "B", "C","D","A"];
- var c=[0,0,0,0,0];
- var count=[0,0,0,0,0];
- for(var i =0 ; i<5 ; i <i++){
- for(var j =0 ; j< 5;j++){
- if(j<i && cars[i]==cars[j]){
- count[j]=0;
- }
- if(cars[i]== cars[j]){
- c[i]++;
- }
- }
- }
- document.getElementById("demo").innerHTML = c;
- var maxi=c[0]
- var maxipos=0;
- var maximum=0;
- for (var i=1;i<5;i++)
- {
- if(c[i]>maxi){
- maxi=c[i];
- maxipos=i;
- }
- maximum=cars[maxipos];
- }
- document.write("the frequent element is " +maximum);
- </script>
- </body>
- </HTML>
Add Comment
Please, Sign In to add comment