4-2.자바스크립트 내장객체(Math)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript">
//<![CDATA[
//1.Math
//document.write(Math.max(10,3,15,200)+"<br />");
//document.write(Math.min(10,3,15,200)+"<br />");
//document.write(Math.ceil()(Math.random()*69+"<br />");
//console.log(Math.round(3.3));
//console.log(Math.ceil(3.3));
//console.log(Math.floor(3.9));
//50~70까지의 값나오게 하기
//Math.floor(Math.random()*(최대값-최소값+1))+최소값
//document.write(Math.floor(Math.random()*21)+50);
//2.로또 만들기
/*
for(i=1; i<=6; i++){
document.write(i+"번공 : "+Math.floor(Math.random()*45)+"<br/>");
}
for(i=1; i<=6; i++){
var ballNum=Math.floor(Math.random()*45);
document.write(i+"번공 : "+ballNum+"<br/>");
}*/
//3.문자객체
//var stringObj=new String("javascript");
//var stringObj="javascript";
//document.write(stringObj.bold());
/*
var s = "Abc Def Fed Cba";
document.write("볼드체: "+s.bold()+"<br/>");
document.write("이테리체: "+s.italics()+"<br/>");
document.write("아래첨자: "+s.sub()+"<br/>");
document.write("폰트 스타일: "+s.fontcolor("blue").fontsize(4)+"<br/>");
document.write("링크: "+s.link("httpt://www.naver.com")+"<br/>");
document.write("글자 총 갯수: "+ s.length+"<br/>");
document.write("소문자로 바꾸기: "+s.toLowerCase()+"<br/>");
document.write("대문자로 바꾸기: "+s.toUpperCase()+"<br/>");
document.write("글자위치찾기: "+s.charAt(10)+"<br/>");
document.write("앞에서 글자 찾기: "+s.indexOf("e")+"<br/>");
document.write("뒤에서 글자 찾기: "+s.lastIndexOf("e")+"<br/>");
document.write("문자추출-어디에서~어디까지: "+s.substring(5,8)+"<br/>");
document.write("문자추출-어디에서,몇글자: "+s.substr(5,8)+"<br/>");
document.write("문자추출 어디에서~어디까지: "+s.replace("Abc","SM")+"<br/>");
var ss=s.split(" ");
document.write(ss[0]+"<br/>");
document.write(ss[1]+"<br/>");
document.write(ss[2]+"<br/>");
document.write(ss[3]+"<br/>");
//맨마지막 글자를 알수있다
alert(s.charAt(s.length-1));
*/
//주민번호 노출처리
/*
var idNum=prompt("주민등록번호를 입력해주세요(-포함)");
document.write(idNum.substr(0,7)+"*******")
*/
//메일주소 입력하기
/*
var myMail=prompt("당신의 메일주소를 입력해주세요");
if(myMail.indexOf("@") == myMail.lastIndexOf("@") && myMail.indexOf("@") >= 0){
alert("등록해주셔서 감사합니다^^");
document.write(myMail);
}else{
alert("잘못된 메일주소입니다.다시등록해주세요^^");
}
*/
//]]>
</script>
</head>
<body>
</body>
</html>