Advertisement
ph4x35ccb

seçao 7 aula 36 JS udemy mudando propiedade obj

May 20th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title></title>
  5. </head>
  6. <body>
  7.     <script>   
  8. function Caneta(preco, cor){
  9.    
  10.     var color = cor || 'balck';
  11.     this.preco = preco || 1;
  12.     this.mudarCor = function(cor){
  13.       if(cor !== 'red' && cor !== 'blue' && cor !== 'black'){
  14.           return;
  15.       }else{
  16.         color = cor;
  17.       }
  18.     }
  19.     this.pegaCor = function(){
  20.       return color;
  21.     }
  22.  }
  23.  var caneta1 = new Caneta(2,'red');
  24.   </script>
  25.  
  26. </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement