SHARE
TWEET

Untitled

Rofihimam Sep 11th, 2019 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Buat Fungsi PBO 2 Rofi'ul Himam XI RPL 2</title>
  5.     <link rel="stylesheet" type="text/css" href="buatfungsi.css">
  6. </head>
  7. <body>
  8.     <p id="coba">
  9.         <script type="text/javascript" language="javascript">
  10.             function SegiEmpat() { }
  11.             function SegiEmpat() {
  12.                 this.panjang = 0;
  13.                 this.lebar = 0;
  14.                 this.hitungLuas = function() {
  15.                     var luas = this.panjang * this.lebar;
  16.                     return luas;
  17.                 }
  18.                 this.hitungKeliling = function() {
  19.                     var kel = 2 * (this.panjang + this.lebar);
  20.                     return kel;
  21.                 }
  22.             }
  23.             //contoh penggunaannya
  24.             var s = new SegiEmpat();
  25.             s.panjang = 4;
  26.             s.lebar = 3;
  27.             alert("Luas adalah " + s.hitungLuas() + " cm");
  28.             alert("dan keliling adalah " + s.hitungKeliling() + " cm")
  29.         </script>
  30.     </p>
  31. </body>
  32. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top