-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects.js
More file actions
27 lines (23 loc) · 704 Bytes
/
objects.js
File metadata and controls
27 lines (23 loc) · 704 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
// Calcula o perímetro e a área de um retângulo
function calcularRetangulo(retangulo) {
let perimetro = 2 * (retangulo.largura + retangulo.altura);
let area = retangulo.largura * retangulo.altura;
return { perimetro, area };
}
// Verifica se uma pessoa é maior de idade
function ehAdulto(pessoa) {
if (pessoa.idade >= 18)
ehAdulto = true
else
ehAdulto = false
return ehAdulto;
}
// Concatena os valores de um objeto em uma string
function concatenaValores(obj) {
let resultado = '';
for (let key in obj) {
resultado += obj[key] + ' ';
}
return resultado.trim();
}
module.exports = { calcularRetangulo, ehAdulto, concatenaValores };