-
Notifications
You must be signed in to change notification settings - Fork 0
/
math.js
92 lines (72 loc) · 1.88 KB
/
math.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
console.group('cuadrado')
const ladoCuadrado = 4;
const perimetroCuadrado = ladoCuadrado * 4;
const areaCuadrado = ladoCuadrado * ladoCuadrado;
function calcularCuadrado(lado){
return{
perimetro:lado*4,
area:lado * lado,
}
}
console.log({
ladoCuadrado,
perimetroCuadrado,
areaCuadrado,
});
console.groupEnd('cuadrado')
console.group('triangulo')
const ladoTriangulo1 = 6;
const ladoTriangulo2 = 6;
const ladoTrianguloBase= 4;
const alturaTriangulo = 5.5;
const perimetroTriangulo= ladoTriangulo1 + ladoTriangulo2 +ladoTrianguloBase;
const areatriangulo = (ladoTrianguloBase*alturaTriangulo)/2;
function calcularAlturaTriaEscaleno(lado1Base, lado2, lado3){
}
function calcularAlturaTriangulo(lado1, base){
if(lado1==base){
console.warn('Este no es un triangulo isosceles');
}else {
//h= raizcuadrada (lado1**2 - (b**2)/2)
const altura= Math.sqrt( (lado1**2) - ((base**2)/4));
return{altura}
// O simplemente hacemos 'return Math.sqrt( (lado1**2) - ((base**2)/4));'
}
}
function calcularPerimetroTriangulo(lado1, lado2, base, altura){
return{
perimetro:lado1 +lado2 +base,
area:(base*altura)/2,
}
}
console.log({
ladoTriangulo1,
ladoTriangulo2,
ladoTrianguloBase,
alturaTriangulo,
perimetroTriangulo,
areatriangulo,
});
console.groupEnd('triangulo')
console.group('circle')
const radioCirculo=3;
const diametroCirculo= radioCirculo*2;
const PI = 3.1415;
const circunferencia = diametroCirculo*PI;
const areaCirculo= (radioCirculo**2)*PI;
console.log({
radioCirculo,
diametroCirculo,
circunferencia,
areaCirculo,
PI,
});
function calcularCirculo(radio){
const diametro= radio*2;
const radioalcuadrado= Math.pow(radio,2);
return{
circunferencia:diametro*Math.PI,
area:radioalcuadrado*Math.PI,
};
}
console.groupEnd('circle')