객체의 활용- 04.html

CODEDRAGON Development/JavaScript, jQuery, ...

반응형

   

객체의 활용

   

소스 코드

  1. <html>
  2. <head>
  3. <meta charset="UTF-8">
  4. <title>객체의 활용</title>
  5. <script type="text/javascript">
  6.         var student = {
  7.                         name:'홍길동',
  8.                         korean:90,
  9.                         math:99,
  10.                         english:88,
  11.                         science:95
  12.         };
  13.         //출력용 변수
  14.         var output = '';
  15.         output += '이름: ' + student.name + '\n';
  16.         output += '국어: ' + student.korean + '\n';
  17.         output += '수학: ' + student.math + '\n';
  18.         output += '영어: ' + student.english + '\n';
  19.         output += '과학: ' + student.science+ '\n';
  20.         output += '총점: ' +  (student.korean + student.math + student.english + student.science) +'\n';
  21.         output += '평균: ' + (student.korean + student.math + student.english + student.science)/4 +'\n';
  22.          
  23.         alert(output);
  24. </script>
  25. </head>
  26. <body>
  27.    
  28. </body>
  29. </html>


   

 

출력결과

   

반응형

'Development > JavaScript, jQuery, ...' 카테고리의 다른 글

후손 선택자- 08.html  (0) 2014.11.25
빈 객체에 속성 추가- 05.html  (0) 2014.11.23
자식선택자- 07.html  (0) 2014.11.18
javascript file 생성  (0) 2014.10.30
참조에 의한 함수 호출 방식- 20.html  (0) 2014.10.29