본문 바로가기

Python_WEB/JavaScript

[Ch9]자바스크립트 객체 연습문제 3

반응형

Q>

Date 객체의 getMonth() 메서드를 이용해 금월의 이름을 출력하는 프로그램을 작성하시오.

월 이름은 배열에 저장하라.

 

A>

<!DOCTYPE html>
<html lang="ko">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Quiz 3</title>
</head>

<body>
    <script>
        var currentMonth = new Date();
        var listMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

        document.write("It is " + listMonths[currentMonth.getMonth()]);
    </script>
</body>

</html>

 

R>

 

HTML5 + CSS3 + JavaScript로 배우는 웹프로그래밍 기초
국내도서
저자 : 천인국
출판 : 인피니티북스 2013.12.19
상세보기
반응형