Advertisement
avr39ripe

jsPrinterMachine

Mar 10th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Study</title>
  6. </head>
  7. <body>
  8.     <div id="output"></div>
  9.     <script>
  10.         `use strict`
  11.  
  12.         function PrinterMachine(fontColor, fontSize, fontFamily, outputId = 'output') {
  13.             this._fontColor = fontColor;
  14.             this._fontSize = fontSize;
  15.             this._fontFamily = fontFamily;
  16.  
  17.             this.print = function(message = 'Nice day to learn JS!')
  18.             {
  19.                 output.innerHTML += `<h2 style="font-size: ${this._fontSize}px; color: ${this._fontColor}; font-family: ${this._fontFamily}"">${message}</h2>`;
  20.            }
  21.  
  22.        }
  23.  
  24.        {
  25.            let printer1 = new PrinterMachine('red', 20, 'sans');
  26.            let printer2 = new PrinterMachine('blue', 50, 'cursive');
  27.  
  28.            printer1.print();
  29.            printer2.print('Nice day to kill DJ ;]');
  30.            printer1.print('London is a capital of... who knows what!? :(')
  31.        }
  32.  
  33.    </script>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement