FALLO DE LA CONSOLA
Publicado por Pedro (18 intervenciones) el 28/01/2021 20:01:39
Buenas he creado este codigo. Intento importar una funcion para poder verla en consola, pero me da error y no entiendo el porque.
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
function restar(pNumero1, pNumero2) {
console.log(pNumero1 - pNumero2);
}
let literal = "Juan Antonio";
module.exports = { restar, literal };
class Producto {
constructor(pTitulo, pPrecio, pCategoria, pCantidad) {
this.titulo = pTitulo;
this.precio = pPrecio;
this.categoria = pCategoria;
this.cantidad = pCantidad;
}
calcularPrecio() {
console.log(this.precio * this.cantidad);
}
mostrarProducto() {
console.log(`${this.titulo}:`);
this.calcularPrecio();
}
}
module.exports = Producto;
const { restar, literal } = require('./functiones');
const Producto = require('./producto')
restar(2, 3);
console.log(literal);
let miProducto = new Producto('Leche', 0.56, 'lacteos', 10);
miProducto.mostrarProducto()
Valora esta pregunta


0