JavaScriptの基本構文でゲームを作る

今日覚えること(30min)


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <img src="https://dol.ismcdn.jp/mwimgs/6/b/670m/img_6b201e1a7a266ad253bf473f846d695e67132.jpg">  
</body>
</html>

<body>
  <img onclick="click_img()" src="https://dol.ismcdn.jp/mwimgs/6/b/670m/img_6b201e1a7a266ad253bf473f846d695e67132.jpg">
  <script>
    function click_img()
    {
      alert('click image!');
    }
  </script>
</body>

<body>
  <img id="first_image" onclick="click_img()" src="https://dol.ismcdn.jp/mwimgs/6/b/670m/img_6b201e1a7a266ad253bf473f846d695e67132.jpg">
  <script>
    function click_img()
    {
      let img = document.getElementById("first_image");
      img.src = "https://amd.c.yimg.jp/im_siggo1AICsEpJBBmjSdFdfEMTg---x400-y397-q90-exp3h-pril/amd/20190728-00010001-sippo-000-1-view.jpg"
    }
  </script>
</body>

オブジェクトについて
var firstObject = {
  name: "松田信介",
  age: 34,
  hobby: ["Ruby", "Unity", "Python", "JavaScript"],
  pet: { name: "tama", type: "猫"},
  sayHello: function(){
    console.log(this.name + this.age);
  }
}