js write input a line of string to count the number of lowercase letters in it

<!DOCTYPE html>
<html leng = 'en'>
 	<head>
  		<meta charset = 'UTF-8'/>
	 </head>
	 <body>
	  	<script>
			var chara = prompt('请输入一行字符串');
			var num = 0;
			for(var i = 0; i < chara.length; i++){
    
    
				if(chara[i].charCodeAt() >= 97 && chara[i].charCodeAt() <= 122){
    
    
					num++;
				} 
			}
			console.log('小写字母的个数是:' + num)
  		</script>
 	</body>
</html>

Guess you like

Origin blog.csdn.net/weixin_48727085/article/details/107706020