013--Hbuilder--js--將字串中所有大寫字母改成小寫,所有小寫字母改成大寫

做夢吃星星發表於2020-10-26
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="shortcut icon" href="//www.baidu.com/favicon.ico" type="image/x-icon"/>
	</head>
	<body>
	</body>
</html>
<script type="text/javascript">
	function rev(str){
		result = "";
		for(i=0;i<str.length;i++){
			if(str[i] < "a"){
				result += str[i].toLowerCase();
			}else{
				result += str[i].toUpperCase();
			}
		}
		return result;
	}
	var newresult = rev("ILikeBeiJing");
	console.log(newresult);
</script>

相關文章