<HTML>
<HEAD>
<TITLE> 자바스크립트 내장객체 p15</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--


document.write(Math.PI+"<br>"); 
document.write(Math.abs(-5)+"<br>"); 
document.write(Math.ceil(5.6)+"<br>"); //올림
document.write(Math.floor(5.6)+"<br>"); 
document.write(Math.max(1,2,3)+"<br>"); 
document.write(Math.min(1,2,3)+"<br>"); 
document.write(Math.round(5.6)+"<br>"); //반올림
document.write(Math.random()+"<br>"); //난수


//문)Math.random()를 이용해서 1~5사이의 정수만 발생시키시오.
document.write((parseInt(Math.random()*5)+1)+"<br>");


 

//문)로또1~45
document.write((parseInt(Math.random()*45)+1)+"<br>");
document.write((parseInt(Math.random()*45)+1)+"<br>");
document.write((parseInt(Math.random()*45)+1)+"<br>");
document.write((parseInt(Math.random()*45)+1)+"<br>");
document.write((parseInt(Math.random()*45)+1)+"<br>");
document.write((parseInt(Math.random()*45)+1)+"<br>");


//숙제 1~45
var lotto=new Array(6);
//lotto배열변수에 중복되지 않게 로또번호를 발생시켜 셋팅하시오
lotto[0]=parseInt(Math.random()*45)+1;
lotto[1]=parseInt(Math.random()*45)+1;
lotto[2]=parseInt(Math.random()*45)+1;
lotto[3]=parseInt(Math.random()*45)+1;
lotto[4]=parseInt(Math.random()*45)+1;
lotto[5]=parseInt(Math.random()*45)+1;

 

var a="5", b="9";
document.write(Number(a)+Number(b));//Number객체
document.write(eval(a)+eval(b));//내장함수
document.write(eval("7+8"));//내장함수

 

var today=new Date();//현재 시스템의 날짜정보를 today변수에 셋팅
document.write(today.getYear()+"<br>");
document.write((today.getMonth()+1)+"<br>");
document.write(today.getDate()+"<br>");
document.write(today.getDay()+"<br>");//요일

document.write(today.getHours()+"<br>");
document.write(today.getMinutes()+"<br>");
document.write(today.getSeconds()+"<br>");

 

//-->
</SCRIPT>
</BODY>
</HTML>

'..열심히 공부하세.. > JavaScript' 카테고리의 다른 글

12 이벤트 (onMouseOver,onMouseOut)  (0) 2008.10.30
11 이중 for문 연습  (0) 2008.10.30
09 변수의 유효범위 Scope  (0) 2008.10.30
08 재귀적 함수 호출  (0) 2008.10.30
07 함수작성, 호출 연습  (0) 2008.10.30

+ Recent posts