隆Te damos la bienvenida a este reto!

1

隆Bienvenido al mundo de JavaScript!

D铆a 1

2

Variables, funciones y sintaxis b谩sica

3

Tipos de datos

4

Playground - Retorna el tipo

5

Tipos de datos - pt 2

D铆a 2

6

Operadores

7

Hoisting y coerci贸n

8

Playground - Calcula la propina

9

Alcance de las variables

D铆a 3

10

Condicionales

11

Playground - Calcula a帽os bisiestos

12

Switch

13

Playground - Obten informaci贸n de mascotas seg煤n su tipo

14

Ciclos

15

Playground - Dibuja un triangulo

D铆a 4

16

Arrays

17

Playground - Encuentra al michi mas famoso

18

Objetos

19

Playground - Obten el promedio de los estudiantes

D铆a 5 - Checkpoint

20

Playground - encuentra el palindromo m谩s grande

D铆a 6

21

Reasignaci贸n y redeclaraci贸n

22

Modo estricto

D铆a 7

23

Debugging y manejo de errores

24

Programaci贸n funcional

Quiz: D铆a 7

D铆a 8

25

Closures

26

Playground - Crea una calculadora con closures

27

Higher order functions

28

Playground - Crea tu propio m茅todo map

D铆a 9

29

ECMAScript

30

TC39

Quiz: D铆a 9

D铆a 10 - Checkpoint

31

ES6

32

ES7

33

Playground - Task planner

D铆a 11

34

Asincronismo

35

Playground - Promesas

36

Manejando el asincronismo

37

Playground - Resuelve el callback hell usando promesas

38

Playground - Resuelve el callback hell usando async/await

D铆a 12

39

Arrays a profundidad

40

M茅todos de arrays: Every, Find y findIndex

41

Playground - V谩lida el formulario

D铆a 13

42

M茅todos de arrays: Includes, Join y concat

43

Playground - agrupa los productos

44

M茅todos de arrays: Flat y FlatMap

45

Playground - Encuentra la ubicaci贸n del valor buscado

D铆a 14

46

Mutable functions

47

Playground - Modifica una lista de compras

48

M茅todos de arrays: sort

49

Playground - Ordena los productos

D铆a 15 - Checkpoint

50

Playground - Sistema de reservaciones de un hotel

D铆a 16

51

Programaci贸n orientada a objetos en JavaScript

52

Objetos literales

53

Playground - Congela el objeto recursivamente

D铆a 17

54

Prototipos en JavaScript

55

Playground - Modifica el prototype de los arrays

56

Playground - Crea un auto usando clases

D铆a 18

57

Abstracci贸n en JavaScript

58

Playground - Sistema de carrito de compras

59

Encapsulamiento en JavaScript

60

Playground - Encapsula datos de los usuarios

D铆a 19

61

Herencia en JavaScript

62

Playground - Jerarqu铆a de animales

63

Polimorfismo en JavaScript

64

Playground - Sistema de pagos

D铆a 20 - Checkpoint

65

Playground - Agenda de vuelos

D铆a 21

66

Patrones de dise帽o

67

Sinlgeton y Factory pattern en JavaScript

68

Playground - Implementa singleton en un chat

D铆a 22

69

Adapter y Decorator pattern en JavaScript

70

Playground - Personaliza productos de una tienda

71

Builder y Protype pattern en JavaScript

72

Playground - Mejora el c贸digo usando builder pattern

D铆a 23

73

Facade y proxy pattern en JavaScript

74

Playground - Proxy en servicio de mensajer铆a

75

Chain of responsability y Observer pattern en JavaScript

76

Playground - Implementaci贸n de Observador en Newsletter

D铆a 24 - Checkpoint

77

Playground - Crea un task manager con patrones de dise帽o

D铆a 25

78

Estructuras de datos en JavaScript

79

Playground - Crea tu propia implementaci贸n de un array

80

Hash tables en JavaScript

81

Playground - Implementaci贸n de una HashTable para Contactos

D铆a 26

82

Set en JavaScript

83

Playground - Remueve duplicados de una lista

84

Maps en JavaScript

85

Playground - Crea un organizador de tareas

D铆a 27

86

Singly Linked List en JavaScript

87

Playground - Agrega m茅todos a la singly linked list

88

Playground - Implementaci贸n de una singly linked list

D铆a 28

89

Stacks en JavaScript

90

Playground - Crea un stack para una playlist

D铆a 29

91

Queues en JavaScript

92

Playground - Crea una cola de emails

D铆a 30

93

隆Lo lograste!

Live Class

94

30 d铆as de JS con Juan DC

95

30 d铆as de JS con Nicobytes

96

30 d铆as de JS con GNDX

97

30 d铆as de JS con LeoCode

98

30 d铆as de JS con Teffcode

99

Sesi贸n: Cierre de los 30 d铆as de JavaScript

No tienes acceso a esta clase

隆Contin煤a aprendiendo! 脷nete y comienza a potenciar tu carrera

Quedan menos de 24 hrs para aprender Ingl茅s, AI y m谩s a precio especial.

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

0 D铆as
11 Hrs
15 Min
52 Seg

Playground - Personaliza productos de una tienda

70/99

Aportes 32

Preguntas 0

Ordenar por:

驴Quieres ver m谩s aportes, preguntas y respuestas de la comunidad?

Muy entendible, listo.

excercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super();
    this.price = price;
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + ' con garant铆a';
  }
}

ShippingInsurance.js


import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + ' con seguro de env铆o';
  }
}

Dejo por mi aporte un aporte. Creo que es mejor declarar siempre las constantes en este caso utilice un objeto para guardar los precios y cadenas del decorador, en todo lo dem谩s se ve igual al resto de soluciones. XD

class ShippingInsuranceDecorator extends Product {

  SHIPPING_INSURANCE = {
    price: 20,
    description: " con seguro de env铆o",
  }

  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + this.SHIPPING_INSURANCE.price;
  }

  getDescription() {
    return this.product.getDescription() + this.SHIPPING_INSURANCE.description;
  }
}
class WarrantyDecorator extends Product {

  WARRANTY = {
    price: 20,
    description: " con garant铆a",
  }

  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + this.WARRANTY.price;
  }

  getDescription() {
    return this.product.getDescription() + this.WARRANTY.description;
  }
}

馃洝锔廍scudo anti-spoilers馃洝锔

aqu铆 mi c贸digo

ShippingInsurance.js


import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con seguro de env铆o";
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con garant铆a";
  }
}

exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = price;
    this.description = description;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description
  }
}
Para aquellos que practicaron bien la clase anterior, debieron encontrar este ejercicio muy f谩cil :). Por cierto, muchas gracias por documentar bien el ejercicio, se pudo entender a la primera. ![](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExOGp6Y2N2dDk2dzJpdjM2Y21rbW1sejRiYmNzMjYxOWNyNXAyenl2ciZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/ZJPSFNLmADueHvzoZ8/giphy.gif) ![](https://static.platzi.com/media/user_upload/code-6300653f-8bad-4d69-9469-ed2dff5ff527.jpg)

Mi solucion:
.
.
.
.
.
.
.
.
.
.
exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con garant铆a";
  }
} 

ShippingInsurance

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con seguro de env铆o";
  }
}

Mi soluci贸n 馃挌
Nada m谩s una nota, tanto en ShippingInsurance como en WarrantyDecorator se nos pide heredar de Product. Sin embargo, por las descripciones solicitadas (y como se observa en el ejemplo) siento que es m谩s prudente si se hereda directamente de BasicProduct. De esa manera se evitan errores por no tener productos sin descripci贸n y se reduce mucho el c贸digo.

exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price)
    this.description = description
  }

  getDescription() {
    return this.description
  }
}

ShippingInsurance.js

import { BasicProduct } from "./exercise";

export class ShippingInsuranceDecorator extends BasicProduct {
  constructor(product) {
    super(product.price + 20, `${product.description} con seguro de env铆o`)
  }
}

WarrantyDecorator.js

import { BasicProduct } from "./exercise";

export class WarrantyDecorator extends BasicProduct {
  constructor(product) {
    super(product.price + 20, `${product.description} con garant铆a`)
  }
}

馃洝锔忦煕★笍馃洝锔廍scudo anti spoilers馃洝锔忦煕★笍馃洝锔

Personaliza productos de una tienda

exercise.js

export class BasicProduct extends Product {
  constructor(price, description) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = price;
    this.description = description;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}

Warranty decorator

export class WarrantyDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.product = product;
    this.product.price += 20;
    this.product.description += " con garantia";
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.description;
  }
}

Shipping Insurance

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + ' con seguro de env铆o';
  }
}
// ShippingInsurance.js
export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con seguro de env铆o`;
  }
}

// WarrantyDecorator.js
export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con garant铆a`;
  }
}
// exercise.js
export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

ShippingInsurance.js

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super(product.getPrice() + 20, product.getDescription() + " con seguro de env铆o");
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con seguro de env铆o";
  }
}

WarrantyDecorator

export class WarrantyDecorator extends Product {
  constructor(product) {
    super(product.getPrice() + 20, product.getDescription() + " con garant铆a");
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con garant铆a";
  }
}

exercise.js

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

Hola mi soluci贸n.











ShippingInsurance.js

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super(product);
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con seguro de env铆o`;
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super(product);
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con garant铆a`;
  }
}

exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

product.js

export class Product {
  // Este c贸digo no debe ser editado 鉂
  constructor(price) {
    this.price = price;
  }

  getPrice() {
    return this.price;
  }

  getDescription() {
    throw new Error("Este m茅todo debe ser implementado en las subclases");
  }
}

Soluci贸n

class BasicProduct extends Product {
  constructor(price, description) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = price;
    this.description = description;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}

export class WarrantyDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = product.price + 20;
    this.description = ` ${product.description} with warranty`;
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.price;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = product.price + 20;
    this.description = ` ${product.description} with shipping insurance`;
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.price;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}

SPOILER!!!
.
.

.
.
.
.


import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.price + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con seguro de env铆o`
  }
}
import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.price + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con garant铆a`
  }
}
import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price)
    this.description =  description
  }

  getDescription() {
    return this.description
  }
}


.
.
.
.
.
.

exercise.js:

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

WarrantyDecorator.js:

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.price + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con garant铆a`
  }
} 

ShippingInsurance.js:

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.price + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con seguro de env铆o`
  }
}

MI SOLUCION 馃挭
.
.
.
.
.
.
.
.
.
.
.
.
.
class BasicProduct

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

class WarrantyDecorator

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super(product.price);
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con garant铆a`;
  
  }
}

class ShippingInsuranceDecorator


import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super(product.price);
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return `${this.product.getDescription()} con seguro de env铆o`;
  }
}

Seguimos, pero por un acento no me pasaba:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

exercise,js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    // Tu c贸digo aqu铆 馃憟 
    super();
    this.price = price;
    this.description = description;
  }
  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.product = product;
  }
  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.getPrice() + 20;
  }
  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.getDescription() + ' con garant铆a';
  }
}

ShippingInsurance.js

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.product = product;
  }
  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.getPrice() + 20;
  }
  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.getDescription() + ' con seguro de env铆o';
  }
}

exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    // Tu c贸digo aqu铆 馃憟
    super(price);
    this.description = description;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}

ShippingInsurance.js

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.product = product;
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.getPrice() + 20;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return `${this.product.getDescription()} con seguro de env铆o`
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.product = product;
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.getPrice() + 20;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return `${this.product.getDescription()} con garant铆a`;
  }
}

馃洝锔忦煕★笍Escudo anti-spoilers馃洝锔忦煕★笍

Mi soluci贸n al reto:

ShippingInsurance.js


import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super()
    this.product = product
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + ' con seguro de env铆o'
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super()
    this.product = product
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + ' con garant铆a'
  }
}

exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price, description)
    this.description = description
    this.price = price
  }

  getDescription() {
    return this.description
  }
}

Aqu铆 mi soluci贸n:
.
.
.
.
.
.
.
.
.
.
.
.
exercise.js

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

WarrantyDecorator .js

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20
  }

  getDescription() {
    return this.product.getDescription() + " con garant铆a"
  }
}

ShippingInsuranceDecorator.js

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20
  }

  getDescription() {
    return this.product.getDescription() + " con seguro de env铆o"
  }
}

Muy bien detallado, creo que es el primero que hago a la primera jeje, aqu铆 dejo mi c贸digo鈥 馃槂

export class BasicProduct extends Product {
  constructor(price, description) {
    // Tu c贸digo aqu铆 馃憟
    super(price);
    this.description = description;

  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}
export class Product {
  // Este c贸digo no debe ser editado 鉂
  constructor(price) {
    this.price = price;
  }

  getPrice() {
    return this.price;
  }

  getDescription() {
    throw new Error("Este m茅todo debe ser implementado en las subclases");
  }
}
export class WarrantyDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = product.price + 20;
    this.description = product.description;
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.price;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return `${this.description} con garant铆a`;
  }
}
export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = product.price + 20;
    this.description = product.description;
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.price;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return `${this.description} con seguro de env铆o`;
  }
}

Hola, dejo mi soluci贸n
.
.
.

.
.
.
.
.

class Product {
  // Este c贸digo no debe ser editado 鉂
  constructor(price) {
    this.price = price;
  }

  getPrice() {
    return this.price;
  }

  getDescription() {
    throw new Error("Este m茅todo debe ser implementado en las subclases");
  }
}

// ShippingInsurance.js
class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
    // Tu c贸digo aqu铆 馃憟
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return parseFloat(this.product.getPrice()) + 20;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return `${this.product.getDescription()} con seguro de env铆o`;
  }
}

// WarrantyDecorator.js
class WarrantyDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.product = product;
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return parseFloat(this.product.getPrice()) + 20;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return `${this.product.getDescription()} con garant铆a`;
  }
}

// exercise.js
class BasicProduct extends Product {
  constructor(price, description) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = price;
    this.description = description;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}

ez el tutorial

mi versi贸n de la soluci贸n, importante revisar lo del control del precio:

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.price = product.price + 20;
    this.description = product.description;
    this.conSeguro = "con seguro de env铆o";
    if (product.conGarantia) {
      this.conGarantia = product.conGarantia;
    } else {
      this.conGarantia = "";
    }
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.price;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    if (this.conGarantia && this.conSeguro) {
      return `${this.description} ${this.conGarantia} ${this.conSeguro}`;
    } else if (this.conGarantia) {
      return `${this.description} ${this.conGarantia}`;
    } else if (this.conSeguro) {
      return `${this.description} ${this.conSeguro}`;
    } else {
      return `${this.description}`;
    }
  }
}
 export class WarrantyDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super();
    this.description = product.description;
    this.price = product.price + 20;
    this.conGarantia = "con garant铆a";
    if (product.conSeguro) {
      this.conSeguro = product.conSeguro;
    } else {
      this.conSeguro = "";
    }
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.price;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    if (this.conGarantia == undefined) {
      return `${this.description}`;
    } else return `${this.description} ${this.conGarantia}`;
  }
}
export class BasicProduct extends Product {
  constructor(price, description) {
    // Tu c贸digo aqu铆 馃憟
    super(price);
    this.description = description;
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description;
  }
}

Soluci贸n鈥 馃槃
.

.
ShippingInsurance.js:
.

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con seguro de env铆o";
  }
}

.
WarrantyDecorator.js:
.

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con garant铆a";
  }
}

.
exercise.js:
.

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

.
product.js:
.

export class Product {
  constructor(price) {
    this.price = price;
  }

  getPrice() {
    return this.price;
  }

  getDescription() {
    throw new Error("Este m茅todo debe ser implementado en las subclases");
  }
}

Es hermoso que en la vista ya venga con informaci贸n de ejemplo para uno no tener que escribirla 馃槉

.
:
:
:
:
:
:
::
:
:

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con seguro de env铆o"
  }
}

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + " con garant铆a"
  }
}

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super();
    this.price = price;
    this.description = description;
  }

  getDescription() {
    return this.description
  }
}

export class Product {
    // Este c贸digo no debe ser editado 鉂
    constructor(price) {
      this.price = price;
    }
  
    getPrice() {
      return this.price;
    }
  
    getDescription() {
      throw new Error("Este m茅todo debe ser implementado en las subclases");
    }
  }

mmm

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

Les comparto mi soluci贸n. 馃槃

ShippingInsurance.js

import { Product } from './product.js';
export class ShippingInsuranceDecorator extends Product {
  product;
  constructor(product) {
    const price = product.price + 20;
    super(price);
    this.product = product;
  }
  getPrice() {
    return super.getPrice();
  }
  getDescription() {
    const DESCRIPTION_PRODUCT = this.product.getDescription();
    const MESSAGE = `${DESCRIPTION_PRODUCT} con seguro de env铆o`;
    return MESSAGE;
  }
}

WarrantyDecorator.js

import { Product } from './product.js';
export class WarrantyDecorator extends Product {
  product;
  constructor(product) {
    const price = product.price + 20;
    super(price);
    this.product = product;
  }
  getPrice() {
    return super.getPrice();
  }
  getDescription() {
    const DESCRIPTION_PRODUCT = this.product.getDescription();
    const MESSAGE = `${DESCRIPTION_PRODUCT} con garant铆a`;
    return MESSAGE;
  }
}

Exercise.js

import { Product } from './product.js';
export class BasicProduct extends Product {
  price;
  description;
  constructor(price, description) {
    super(price);
    this.price = price;
    this.description = description;
    this.description = description;
  }
  getDescription() {
    return this.description;
  }
}

Mi respuesta
.
Exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }
  getPrice() {
    return this.price;
  }
  getDescription() {
    return this.description;
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }
  getPrice() {
    return this.product.getPrice() + 20;
  }
  getDescription() {
    return this.product.getDescription() + ' con garant铆a';
  }
}

ShippingInsurance.js

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }
  getPrice() {
    return this.product.getPrice()+20;
  }
  getDescription() {
    return this.product.getDescription() + ' con seguro de env铆o';
  }
}

Mi soluci贸n:
.
.
.
.
.
.

product.js

export class Product {
  // Este c贸digo no debe ser editado 鉂
  constructor(price) {
    this.price = price;
  }

  getPrice() {
    return this.price;
  }

  getDescription() {
    throw new Error("Este m茅todo debe ser implementado en las subclases");
  }
}

exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price)
    this.description = description
  }

  getDescription() {
    return this.description
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super()
    this.product = product
  }

  getPrice() {
    return this.product.getPrice() + 20
  }

  getDescription() {
    return this.product.getDescription() + " con garant铆a"
  }
}

ShippingInsurance.js

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super()
    this.product = product
  }

  getPrice() {
    return this.product.getPrice() + 20
  }

  getDescription() {
    return this.product.getDescription() + " con seguro de env铆o"
  }
}

mi soluci贸n:
c贸digo de exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price);
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}

c贸digo de WarrantyDecorators.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + ' con garant铆a';
  }
}

c贸digo de ShippingInsurance.js


import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super();
    this.product = product;
  }

  getPrice() {
    return this.product.getPrice() + 20;
  }

  getDescription() {
    return this.product.getDescription() + ' con seguro de env铆o';
  }
}

ShippingInsurance.js


import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super(product.getPrice() + 20)
    this.description = `${product.getDescription()} con seguro de env铆o`
  }

  getPrice() {
    return this.price;
  }

  getDescription() {
    return this.description
  }
}

WarrantyDecorator.js

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super(product.getPrice() + 20)
    this.description = `${product.getDescription()} con garant铆a`
  }

  getPrice() {
    return this.price
  }

  getDescription() {
    return this.description;
  }
}

exercise.js

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price)
    this.price = price
    this.description = description
  }

  getDescription() {
    return this.description
  }
}

Product.js

export class Product {
  // Este c贸digo no debe ser editado 鉂
  constructor(price) {
    this.price = price;
  }

  getPrice() {
    return this.price;
  }

  getDescription() {
    throw new Error("Este m茅todo debe ser implementado en las subclases");
  }
}

Mi soluci贸n:

exercise.js:

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super()
    this.price = price
    this.description = description
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.description
  }
}

WarrantyDecorator.js:

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super()
    this.product = product
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
   return this.product.price += 20
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.description += ' con garant铆a'
  }
}

ShippingInsurance.js:


import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    // Tu c贸digo aqu铆 馃憟
    super()
    this.product = product
  }

  getPrice() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.price += 20
  }

  getDescription() {
    // Tu c贸digo aqu铆 馃憟
    return this.product.description += ' con seguro de env铆o'
  }
}

Mi soluci贸n
*
*
*
*
*
*
*
*
*

ShippingInsuranceDecorator

import { Product } from "./product";

export class ShippingInsuranceDecorator extends Product {
  constructor(product) {
    super(product.price)
    this.description = product.description
  }

  getPrice() {
    return this.price + 20
  }

  getDescription() {
    return `${this.description} con seguro de env铆o`
  }
}

WarrantyDecorator

import { Product } from "./product";

export class WarrantyDecorator extends Product {
  constructor(product) {
    super(product.price)
    this.description = product.description
  }

  getPrice() {
    return this.price + 20
  }

  getDescription() {
    return `${this.description} con garant铆a`
  }
}

BasicProduct

import { Product } from "./product";

export class BasicProduct extends Product {
  constructor(price, description) {
    super(price)
    this.description = description;
  }

  getDescription() {
    return this.description;
  }
}
undefined