-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclase12.js
More file actions
31 lines (25 loc) · 701 Bytes
/
clase12.js
File metadata and controls
31 lines (25 loc) · 701 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
var Martin = {
nombre: 'Martin',
apellido: 'Maceda',
edad: 28,
peso: 65
}
console.log(`Al Inicio del ano ${Martin.nombre} pesa: ${Martin.peso}kg`);
//function aumentarPeso (persona) {
// return persona.peso += 200
//}
const CAMBIO_PESO = 0.2
const DIAS_DEL_ANO = 365
const aumentarPeso = (persona) => persona.peso += CAMBIO_PESO
const adelgazar = (persona) => persona.peso -= CAMBIO_PESO
for (var i = 1; i <= DIAS_DEL_ANO; i++) {
var random = Math.random()
if(random < 0.25) {
//aumenta de peso
aumentarPeso(Martin)
} else if (random < 0.5) {
// adelgazar
adelgazar(Martin)
}
}
console.log(`Al final del ano ${Martin.nombre} pesa: ${Martin.peso.toFixed(1)}kg`);