js实现字符串比较

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			// 找出字符串中“how are you doing?”中所有小于字母“s”的字符,并在页面输出
			window.onload = function(){
				var txt = "how are you doing?";
				var ts = "s";
				// console.log(txt.length);
				for(var i = 0; i <= txt.length; i++){
					var t = txt.charAt(i);
					console.log(t);
					if(ts > t){
						document.write(t+'、');
					}
				}

			}
		</script>
	</head>
	<body>
	</body>
</html>

posted @ 2020-03-19 21:41  JackieDYH  阅读(11)  评论(0)    收藏  举报  来源