변수 실습, 보충

Suji Park·2022년 5월 20일
0
post-thumbnail


<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script>
  var no_1 = 1, no_2 = 2, no_3 = 3;

  function one(){
    alert (no_1 + no_2 + no_3)
  };
  
  function two() {
    alert (no_1 - no_2);
  };
  function three() {
    alert (no_1 / no_2);
  };

  function four () {
    alert (no_1 * no_2 );
  };

  one()
  two()
  three()
  four()
</script>
<body>

</body>
</html>

<html>
  <head>
    <script>
      
        var string_1 = '홍길동', string_2 = '안녕', string_3 = '하세요';
    
        function hi() {
         alert(string_1 + string_2 + string_3);
        };
        function hello() {
         alert(string_1 + '님, ' + string_2 + string_3 + '!');
        };
        
        hi();
        hello();
    </script>
  </head>
</html>

a,b,c라는 변수에 값을 할당한 후,그 값들을 모두 더하는 코드를 작성.

var a = 1, b =2, c = 3;
function plus(){
    alert (a + b + c);
};
plus();

변수4개를만들고, 각각의 변수에 값을 할당한 후,그 값들을 모두 곱하는 코드를 작성.

var a = 1, b =2, c = 3, d = 4;
function multiply(){
    alert (a * b * c * d);
};
multiply();
profile
천방지축😛 얼레벌레🙄 빙글빙글🙃 돌아가는 수지의 코드~🎵

0개의 댓글