-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathaula06.02.html
More file actions
38 lines (31 loc) · 996 Bytes
/
aula06.02.html
File metadata and controls
38 lines (31 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!doctype html>
<html>
<head>
<title>Logica de Programação Javascript</title>
<meta charset="utf-8">
</head>
<body>
<h1>Lógica de programação com Javascript</h1>
<div id="output"></div>
</body>
<script>
var produto1 = new Object();
produto1.nome = "caneta";
produto1.preco = 2.2;
produto1.estoque = 10;
produto1.comprar = function(qtd){
if(!qtd) {
qtd = 1;
}
console.log('comprou caneta');
//this.estoque--;
this.estoque = this.estoque - qtd;
console.log(this.estoque);
}
var msg = '';
msg += 'nome: ' + produto1.nome + '<br>';
msg += 'preco: ' + produto1.preco + '<br>';
msg += 'estoque: ' + produto1.estoque + '<br>';
document.querySelector('#output').innerHTML = msg;
</script>
</html>