-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex-07-object.js
More file actions
39 lines (26 loc) · 848 Bytes
/
ex-07-object.js
File metadata and controls
39 lines (26 loc) · 848 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
39
'use strict';
//Exercício - Criar objeto de operações com as operações matemáticas básicas.
let operandos = {
operando1 : 3,
operando2 : 4
};
operandos.soma = function(p1 = operandos.operando1, p2 =operandos.operando2){
return p1 + p2;
};
operandos.subtracao = function(p1 = operandos.operando1, p2 =operandos.operando2){
return p1 - p2;
};
operandos.multiplicacao = function(p1 = operandos.operando1, p2 =operandos.operando2){
return p1 * p2;
};
operandos.divisao = function(p1 = operandos.operando1, p2 =operandos.operando2){
if (p2 != 0) {
return p1 / p2;
}else {
return 'Divisor igual a zero!';
}
};
console.log('Soma:' + operandos.soma());
console.log('Subtracao:' + operandos.subtracao());
console.log('Multiplicacao:' + operandos.multiplicacao());
console.log('Divisao:' + operandos.divisao());