2016년 10월 17일 월요일

숫자, 문자

Math.pow(3,2); // 9, 3의 2승
Math.round(10.6); // 11, 10.6을 반올림
Math.ceil(10.2); // 11, 10.2를 올림
Math.floor(10.6); // 10, 10.6을 내림
Math.sqrt(9); // 3, 3의 제곱근
Math.random(); // 0부터 1.0 사이의 랜덤한 숫자

alert(typeof "1") 결과 : string
alert(typeof 1) 결과 : number

-문자열 안에 따옴표 넣기
alert('egoing\'s javascript')

-줄 바꿈
alert("안녕하세요.\n생활코딩의 세계에 오신 것을 환영합니다"); 

-문자 붙이기
alert("coding"+" everybody");

댓글 없음:

댓글 쓰기