JavaScript - Ayuda con un calculador. No me devuelve los resultado (const-return). Que estoy haciendo mal?

 
Vista:

Ayuda con un calculador. No me devuelve los resultado (const-return). Que estoy haciendo mal?

Publicado por let (1 intervención) el 23/07/2020 19:26:13
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
<table id="calculadora" class="display" width:70%>
    <thead>
        <tr>
            <th>Producto</th>
            <th>Precio</th>
            <th>Viales carga</th>
            <th>Viales Mes</th>
            <th>Costo mes carga</th>
            <th>Costo mes promedio</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Vectibix®</td>
            <td><input type="number" id="vec_precio" name="vec_precio" value="$"></td>
            <td>&nbsp;</td>
            <td><input type="number" id="vec_viales_mes" name="vec_viales_mes" value=""></td>
            <td>7</td>
            <td><label id="vec_costo_mes_prom">$</label></td>
 
        </tr>
        <tr>
            <td>Cetuximab</td>
            <td><input type="text" id="cet_precio" name="cet_precio" value="$"></td>
            <td><input type="text" id="cet_viales_carga" name="cet_viales_carga" value=""></td>
            <td><input type="text" id="cet_viales_mes" name="cet_viales_mes" value=""></td>
            <td><label id="cet_costo_mes_carga">$</label></td>
            <td><label id="cet_costo_mes_prom">$</label></td>
        </tr>
    </tbody>
</table>
<table id="ahorro" class="display" width:50%>
    <thead>
        <tr>
            <th>Ahorros por paciente</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Diferencia mes carga</td>
            <td><label id="dif_mes_carga">$</label></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>Diferencia mes promedio</td>
            <td><label id="dif_mes_prom">$</label></td>
        </tr>
        <tr>
            <td>Diferencia tratamiento completo</td>
            <td><label id="dif_trat_completo">$</label></td>
        </tr>
    </tbody>
</table>
 
<script type="text/javascript">
 
    function calculadora(
      vec_precio,
      vec_viales_mes,
      cet_precio,
      cet_viales_carga,
      cet_viales_mes
    ) {
      const cet_costo_mes_carga = cet_precio * cet_viales_carga;
      const cet_costo_mes_prom = cet_precio * cet_viales_mes;
      const vec_costo_mes_prom = vec_precio * vec_viales_mes;
 
      const dif_mes_carga = cet_costo_mes_carga - vec_costo_mes_prom;
      const dif_mes_prom = cet_costo_mes_prom - vec_costo_mes_prom;
      const dif_trat_completo = dif_mes_carga + dif_mes_prom * 6;
 
      return {
        cet_costo_mes_carga,
        cet_costo_mes_prom,
        vec_costo_mes_prom,
        dif_mes_carga,
        dif_mes_prom,
        dif_trat_completo,
      };
    }
</script>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de joel
Val: 3.506
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

Ayuda con un calculador. No me devuelve los resultado (const-return). Que estoy haciendo mal?

Publicado por joel (895 intervenciones) el 24/07/2020 08:48:28
He revisado tu código, pero no veo cuando llamas a la función calculadora()... este es todo el código?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar