<script language="javascript" type="text/javascript"> function check_odd_even() { var str = prompt("Enter your word to count the Capital and Small Letters."); var count=0,small=0; var len=str.length; for(var i=0;i<len;i++) { if(/[A-Z]/.test(str.charAt(i))) { count++; } else { small++; } } document.write("<h3 style='text-align:center;'><b style='color:blue;'>Orignal word :</b> <b style='color:red;'>" + str + "</b> <br> No. of Capital Letters is <b style='color:blue;'>" +count + "</b>. </h3>"); document.write("<h3 style='text-align:center;'><b style='color:blue;'>Orignal word :</b> <b style='color:red;'>" + str + "</b> <br> No. of Small Letters is <b style='color:blue;'>" +small + "</b>. </h3>"); return count; } </script>