Wednesday, 7 June 2023

Char count in java script

 


<html>
   

<script>

function charCount( name, inputChar)
{

    var count=0;

     var charCount= name.length;
     

     for(var i=0;i<charCount;i++)
     {

        var charVal=name.charAt(i)
       
        var charVal=name.charAt(i)
        if(charVal==inputChar)
        {
            console.log('Yes i find '+ inputChar+' here');
            count=count+1;
        }
     }

     alert('Total no of '+inputChar+' char is '+count);

}

charCount('suchil,kumar,pradhan','z');


</script>



<body></body>

</html>

No comments:

Post a Comment

06/20/024 ( TODO)

Q1 : Create array , add element ,remove element , and update the element  Q2: Show me how overloading and overriding work in inheritance wit...