隆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

Playground - Encapsula datos de los usuarios

60/99

Aportes 45

Preguntas 3

Ordenar por:

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

Recalcar que en las pruebas sale Usuario en espa帽ol en vez de User en ingles, las 鈥渂oberias鈥 atrasan鈥 馃槂

class User {
    // Tu c贸digo aqu铆 馃憟
    constructor(name,age){
        this._name=name;
        this._age=age;
        this._friends=[];
        this._messages=[];
    }
    addFriend(friend){
        this._friends.push(friend);
    }
    sendMessage(message, friend){
        this._messages.push(message);
        friend._messages.push(message);
    }
    showMessages(){
        return this._messages;
    }
    get name(){
        return this._name;
    }
    set name(name){
       if(name.length>0){
         this._name=name;   
    }   else{
        throw new Error("Agregue un nombre v谩lido");
    }  
    }
    get age(){
        return this._age;
    }
    set age(age){
        if(age>0){
            this._age=age;
        }else{
            throw new Error("Agregue una edad v谩lida");
        }
    }

  }


.
.
.
.
.
.

export class User {
    constructor(name, age, friends = [], messages = []) {
      this._name = name;
      this._age = age;
      this._friends = friends;
      this._messages = messages;
    }
  
    get name() {
      return this._name;
    }
    set name(newName) {
      this._name = newName;
    }
    get age() {
      return this._age;
    }
    set age(newAge) {
      this._age = newAge;
    }
  
    addFriend(friend) {
      this._friends.push(friend);
    }
  
    sendMessage(message, friend) {
      this._messages.push(message);
      friend._messages.push(message)
    }
  
    showMessages() {
      return this._messages;
    }
}

Si entendieron bien las ultimas dos lecciones, ser谩 bien sencillo completar este reto 馃槂

Sin embargo no puedo dejar de mencionar esto. Trabajo dentro de la industria y estoy haciendo este curso para mejorar mis habilidades y conocimientos en javascript. En algunas ocasiones la documentaci贸n en estos retos tiende a ser algo confusa y en otros casos se omiten ciertas informaciones que son necesarias para cumplir el reto. Tomen en cuenta que otros participantes est谩n iniciando en este hermoso mundo de la programaci贸n y este tipo de cosas puede llegar a frustrar cuando no sabes como resolverlo.

En mi fue solo un comentario amistoso para mejorar 馃槂
Aqui les comparto mi soluci贸n:

Comparto mi solucion ```js export class User { constructor(name, age) { this._name = name; this._age = age; this._friends = []; this._messages = []; } addFriend(friend) { this._friends.push(friend); } sendMessage(message, friend) { this._messages.push(message); const searchFriend = this._friends.find(amigo => amigo === friend); if(searchFriend) { friend._messages.push(message); } else { return "No tienes en tu lista de amigos a la persona que buscas"; } } showMessages() { return this._messages; } get name() { return this._name; } set name(newName) { if(newName === "") { return "El nombre no puede estar vacio"; } else { this._name = newName; } } get age() { return this._age; } set age(newAge) { if(newAge <= 0) { return "La edad debe no puede ser cero o negativo"; } else { this._age = newAge; } } } ```

Mi aporte:
//
//
//
//
//
//
//
//
//
//

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  get name() {
    return this._name;
  }

  set name(newName) {
    return (this._name === '') ? 'El nombre no puede estar vacio' : this._name = newName;
  }

  get age() {
    return this._age;
  }

  set age(newAge) {
    return (this._age < 0) ? 'No es posible tener una edad menor a 0' : this._age = newAge;
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    this._messages.push(message);
    friend._messages.push(message);
  }

  showMessages() {
    return this._messages;
  }
}

Mi aporte

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  get age() {
    return this._age;
  }

  get name() {
    return this._name;
  }

  set name(name) {
    this._name = name;
  }
  set age(age) {
    this._age = age;
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    this._messages.push(message);
    friend._messages.push(message);
  }

  showMessages() {
    return this._messages;
  }
}

Desafio superado!


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

Encapsula datos del usuaio

export class User {
  // Tu c贸digo aqu铆 馃憟
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  // Setters

  set message(newMessage) {
    if (newMessage !== "") {
      this._messages.push(newMessage);
    }
  }

  set name(newName) {
    if (newName !== "") {
      this._name = newName;
      return;
    }
    throw new Error("The name must not be empty");
  }

  set age(newAge) {
    if (newAge > 0) {
      this._age = newAge;
      return;
    }
    throw new Error("The new age should be positive");
  }

  // Getters

  get name() {
    return this._name;
  }

  get age() {
    return this._age;
  }

  addFriend(amigo) {
    if (amigo instanceof User) {
      this._friends.push(amigo);
    }
  }

  sendMessage(message, friend) {
    if (typeof message === "string" && friend instanceof User) {
      this._messages.push(message);
      friend.message = message;
    }
  }

  showMessages() {
    return this._messages;
  }
}

Mi soluci贸n 馃挌

.
.
.
.

class User {
  constructor(name, age) {
    this._name = name
    this._age = age
    this._friends = []
    this._messages = []
  }

  addFriend(friend) {
    this._friends.push(friend)
  }

  sendMessage(message, friend) {
    this._messages.push(message)
    friend._messages.push(message)
  }

  showMessages() {
    return this._messages
  }

  get name() {
    return this._name
  }

  set name(name) {
    this._name = name
  }

  get age() {
    return this._age
  }

  set age(age) {
    this._age = age
  }

}
export class User {
  constructor(name, age) {
    this._name = name
    this._age = age
    this._friends = [] // obj[]
    this._messages = [] // string[]
  }

  addFriend(friend) {
    this._friends.push(friend)
  }

  sendMessage(message, friend) {
    this._messages.push(message)
    friend._messages.push(message)
  }

  showMessages() {
    return this._messages
  }

  get name() {
    return this._name
  }
  set name(string) {
    if (typeof string === "string" && string.length !== 0) {
      this._name = string
    }
  }
  get age() {
    return this._age
  }
  set age(n) {
    if (n > 0) {
      this._age = n
    }
  }
}

Mi aporte:
|
|
|
|
|
|
|
|
|

export class User {
  // Tu c贸digo aqu铆 馃憟
  constructor(name, age) {
    this._name= name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }
  get name() {
    return this._name;
  }
  set name(newName) {
    this._name = newName;
  }

  get age() {
    return this._age;
  }

  set age(number) {
    this._age = number;
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    this._messages.push(message);
    friend._messages.push(message);
  }

  showMessages() {
    return this._messages;
  }
}
 

Hola, Comparto la soluci贸n del Reto:














export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    this._messages.push(message);
    friend?.sendMessage(message, null);
  }

  showMessages() {
    return this._messages;
  }

  get name() {
    return this._name;
  }

  set name(newName) {
    this._name = newName;
  }

  get age() {
    return this._age;
  }

  set age(newAge) {
    this._age = newAge;
  }
}
export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  addFriend(friend) {
    this._friends.push(friend)
  }
  sendMessage(message, friend) {
    this._messages.push(message)
    friend._messages.push(message);
  }
  showMessages() {
    return this._messages;
  }
  get name() {
   return this._name;
  }
  set name(newName) {
    this._name = newName;
  }
  get age() {
    return this._age;
  }
  set age(newAge) {
    this._age = newAge;
  }
}

Mi soluci贸n:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export class User {
    constructor(name,age){
        this._name=name;
        this._age=age;
        this._friends = [];
        this._messages = [];
    }
    get name(){
        return this._name;
    }
    addFriend(friend){
        this._friends.push(friend);
    }
    sendMessage(message,friend){
        this._messages.push(message);
        friend._messages.push(message);
    }
    showMessages(){
        return this._messages;
    }
    set name(newName){
        this._name = newName;
    }
    get age(){
        return this._age;
    }
    set age(newAge){
        this._age = newAge;
    }
}

Mi soluci贸n

export class User {
  constructor(name, age, friends = [], messages = []) {
    this._name = name;
    this._age = age;
    this._friends = friends;
    this._messages = messages;
  }

  get name() {
    return this._name;
  }
  set name(newName) {
    this._name = newName;
  }
  get age() {
    return this._age;
  }
  set age(newAge) {
    this._age = newAge;
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {

    this._messages.push(message);

    if (friend) {
      friend.sendMessage(message)
    }
  }

  showMessages() {
    return this._messages;
  }

}

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

Mi soluci贸n al reto:

export class User {
  constructor(name, age, friends, messages) {
    this._name = name;
    this._age = age;
    this._friends = friends || [];
    this._messages = messages || [];
  }

  addFriend(friend) {
    this._friends.push(friend)
  }

  set message(msg) {
    this._messages.push(msg)
  }

  sendMessage(message, friend) {
    // buscar al amigo y agregarle el mensaje
    console.log('hola amigo ', friend.name, friend)
    this._friends = this._friends.map((user) => {
      if (user.name === friend.name) {
        console.log('aqui', user.name, friend.name)
        user.message = message
        console.log('mensajes', user)
      }
      return user
    })
    this.message = message
  }

  showMessages() {
    return this._messages
  }

  get name() {
    return this._name;
  }

  set name(value) {
    this._name = value
  }

  get age() {
    return this._age
  }

  set age(age) {
    this._age = age
  }

}

Curiosamente ChatGPT usa # para marcar los elementos privados, y por otro lado si defino las variables privadas fuera del constructor parece no funcionar, por lo que he tenido que adaptar solucion
,
,
,
,
,
,
,
,
,
,

export class User {

  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    this._messages.push(`${message}`);
    friend._messages.push(`${message}`);
  }

  showMessages() {
    return this._messages;
  }

  // Getters y setters
  get name() {
    return this._name;
  }

  set name(newName) {
    this._name = newName;
  }

  get age() {
    return this._age;
  }

  set age(newAge) {
    this._age = newAge;
  }
}

.
.
.
.
.
.
.
Original de GPT4

class Usuario {
  #name;
  #age;
  #friends = [];
  #messages = [];

  constructor(name, age) {
    this.#name = name;
    this.#age = age;
  }

  addFriend(friend) {
    this.#friends.push(friend);
    friend.#friends.push(this);
  }

  sendMessage(message, friend) {
    this.#messages.push(`Yo: ${message}`);
    friend.#messages.push(`${this.#name}: ${message}`);
  }

  showMessages() {
    return this.#messages;
  }

  // Getters y setters
  get name() {
    return this.#name;
  }

  set name(newName) {
    this.#name = newName;
  }

  get age() {
    return this.#age;
  }

  set age(newAge) {
    this.#age = newAge;
  }
}

// Ejemplo de uso
const usuario1 = new Usuario("Juan", 20);
const usuario2 = new Usuario("Maria", 25);

usuario1.addFriend(usuario2);
usuario1.sendMessage("Hola Maria!", usuario2);

console.log(usuario1.showMessages()); // ["Yo: Hola Maria!"]
console.log(usuario2.showMessages()); // ["Maria: Hola Maria!"]

Solucion

class User {
  #name;
  #age;
  #friends;
  #messages;

  constructor(name, age) {
    this.#name = name;
    this.#age = age;
    this.#friends = [];
    this.#messages = [];
  }

  addFriend(friend) {
    this.#friends.push(friend);
  }

  sendMessage(message, friend) {
    if (this.#friends.some((user) => friend.#name === user.#name)) {
      this.#messages.push(message);
    }
    
  }

  showMessages() {
    console.log(this.#messages);
    return this.#messages;
  }

  get #privateName() {
    return this.#name;
  }

  set #privateName(newName) {
    this.#name = newName;
    return this.#name;
  }

  get #privateAge() {
    return this.#age;
  }

  set #privateAAge(newAge) {
    this.#age = newAge;
    return this.#age;
  }
}

馃洝锔廍scudo anti-spoilers馃洝锔

Mi solucion:

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }
  addFriend(friend) {
    this._friends.push(friend)
  }
  sendMessage(message, friend) {
    const users = [this, friend]
    for (const user of users) {
      user.addMessage(message)
    }
  }
  addMessage(message) {
    this._messages.push(message)
  }
  showMessages() {
    return this._messages
  }

  get name() {
    return this._name
  }
  set name(name) {
    this._name = name
  }
  get age() {
    return this._age
  }
  set age(age) {
    this._age = age
  }
}

mi Aporte, hice algunas implicaciones,

export class User {
  constructor(name, age, friends, messages) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }
  addFriend(friend) {
    if (!this._friends.find(x => x.name == friend.name)) {
      this._friends.push(friend);
    }
  }
  sendMessage(message, friend) {
    if (this._friends.find(x => x.name == friend.name)) {
      this._messages.push(message);
      friend._messages.push(message);

    }
  }

  showMessages() {
    return this._messages;
  }

  get name() {
    return this._name;
  }
  set name(newName) {
    if (newName != '') {
      this._name = newName;
    } else {
      throw new Error('El Nombre no es valido');
    }
  }
  get age() {
    return this._age;
  }
  set age(newAge) {
    if (newAge != 0) {
      this._age = newAge;
    } else {
      throw new Error('la Edad no es valida');
    }
  }

}

Mi solucion
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,

class User {
    constructor(name, age) {
        this._name = name,
        this._age = age,
        this._friends = [],
        this._messages = []
    }
    addFriend(friend) {
        this._friends.push(friend)
    }
    sendMessage(message, friend) {
        console.log(friend);
        if (this._friends.some(friendAdded =>friendAdded._name === friend._name)) {            
            this._messages.push(message) && friend._messages.push(message)
        }else {
            console.log('no tienes a este usuario agregado a tu lista de amigos');
        }
    }
    showMessages() {
        return this._messages
    }
    get name() {
        return this._name;
    }
    set name(newName) {
        !newName ? console.log("El nombre no puede estar vac铆o") : this._name = newName
    }
    get age() {
        return this._age;
    }
    set age(newAge) {
        newAge <= 0 ? console.log("La edad no puede ser un numero negativo") : this._age = newAge
    }
}

Aqui esta es que todav铆a me cuesta entender, pero creo que ya me estoy dando una idea
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export class User {
  // Tu c贸digo aqu铆 馃憟
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }
  get name() {
    return this._name;
  }
  set name(name) {
    this._name = name;
  }
  get age() {
    return this._age;
  }
  set age(age) {
    this._age = age;
  }
  addFriend(friend) {
    this._friends.push(friend);
  }
  sendMessage(message, friend) {
    this._messages.push(message);
    friend._messages.push(message);
  }
  showMessages() {
    return this._messages;
  }
}

隆Hola, Desaf铆o cumplido 馃槂!

Mi soluci贸n,
Se detalla hasta abajo.猬









export class User {
  constructor(name, age) {
    this._name     = name;
    this._age      = age;
    this._friends  = [];
    this._messages = [];
   
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend=null) {
    this._messages.push(message);
    if (friend!=null)
      friend.sendMessage(message);
  }
  showMessages()
  {
    return this._messages;
  }

  get name() {
    return this._name;
  }

  set name(newName) {
    if (newName === "") {
      throw new("El nombre no puede estar vac铆o");
    } else {
      this._name = newName;
    }
  }
  get age() {
    return this._age;
  }

  set age(newAge) {
    if (newAge === 0) {
      throw new("La edad no puede ser 0");
    } else {
      this._age = newAge;
    }
  }
}

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

export class User {
  constructor(name, age) {
    this._name = name
    this._age = age
    this._friends = []
    this._messages = []
  }

  //agrega un usuario a la lista de amigos del usuario actual.
  addFriend(friend) {
    this._friends.push(friend);
  }

  //agrega un mensaje a la lista de mensajes del usuario actual y al amigo especificado.
  sendMessage(message, friend) {
    this._messages.push(message);
    let index = this._friends.findIndex(item => item.name === friend.name)
    if (index >= 0) {
      friend.message = message;
    }
  }

  //devuelve la lista de mensajes del usuario actual
  showMessages() {
    return this._messages;
  }

  //para los datos privados como el nombre y la edad, 
  get name() {
    return this._name;
  }

  set name(newname) {
    this._name = newname;
  }

  get age() {
    return this._age;
  }

  set age(newage) {
    this._age = newage;
  }

  set message(newmessage) {
    this._messages.push(newmessage);
  }
}
export class User {
  // Tu c贸digo aqu铆 馃憟
  constructor(name, age) {
    this._name = name
    this._age = age
    this._friends = []
    this._messages = []
  }

  addFriend(friend) {
    this._friends.push(friend)
  }

  sendMessage(message, friend) {
    const index = this._friends.findIndex((f) => friend.name === f.name)
    console.log(this._friends[index])
    this._friends[index].messages.push(message)
    this._messages.push(message)
  }

  showMessages() {
    return this._messages
  }

  get age() {
    return this._age
  }
  
  set age(value) {
    this._age = value
  }

  get name() {
    return this._name
  }

  set name(value) {
    this._name = value
  }

  get messages() {
    return this._messages
  }

  set messages(value) {
    this._messages = value
  }

}

Hola, comparto mi soluci贸n:











export class User {
  constructor(name, age, friends = [], messages = []) {
    this._name = name
    this._age = age
    this._friends = friends
    this._messages = messages
  }

  get name() {
    return this._name
  }

  set name(name) {
    this._name = name
  }

  get age() {
    return this._age
  }

  set age(age) {
    this._age = age
  }

  addFriend(friend) {
    this._friends.push(friend)
  }

  sendMessage(message, friend) {
    this._messages.push(message)
    friend.getMessage(message)
  }

  getMessage(message) {
    this._messages.push(message)
  }

  showMessages() {
    return this._messages
  }

}

驴Porque en el m茅todo sendMessage se accede a la variable privada _messages del usuario friend? se supone que es privada y no se deber铆a poder modificar de esta forma.

sendMessage(message, friend) {
	this._messages.push(message);
	friend._messages.push(message);
}

Creo que la mejor manera de hacer esto ser铆a definiendo un setter para la propiedad _messages.

pd: Esta soluci贸n es la que se muestra despu茅s de quedarse sin intentos.

Agregue un nuevo setter para poder acceder a la variable privada _.messages de friend

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  addFriend(friend) {
    this._friends.push(friend);
  }
  sendMessage(message, friend) {
    this._messages.push(message);
    friend.message = message;
  }
  showMessages() {
    return this._messages;
  }
  get age() {
    return this._age;
  }
  get name() {
    return this._name;
  }
  set age(newAge) {
    this._age = newAge;
  }
  set name(newName) {
    this._name = newName;
  }
  set message(newMessage) {
    this._messages.push(newMessage);
  }
}

Hola, me gustar铆a compartirles mi soluci贸n
.
.
.
.
.
.
.
.
.
.
.
.

class User {
    constructor(name, age) {
        this._name = name;
        this._age = age;
        this._friends = [];
        this._messages = [];
    }

    set name(newName) {
        this._name = newName;
    }
    get name() {
        return this._name;
    }

    set age(newAge) {
        this._age = newAge;
    }
    get age() {
        return this._age;
    }

    addFriend(friend) {
        this._friends.push(friend);
    }

    sendMessage(message, friend) {
        this._messages.push(message);
        friend.receiveMessage(message);
    }

    receiveMessage(message) {
        this._messages.push(message);
    }

    showMessages() {
        return this._messages;
    }
}

Mi solucion:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  get name() {
    return this._name;
  }

  set name(name) {
    this._name = name;
  }

  get age() {
    return this._age;
  }

  set age(age) {
    this._age = age;
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    if (this._friends.includes(friend)) {
      this._friends.find(() => friend)._messages.push(message);
      this._messages.push(message);
    }
  }

  showMessages() {
    return this._messages;
  }
}

Mi solucion:

.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.
.

.

export class User {

  // atributes
  _friends = [];
  _messages = [];

  constructor(name, age) {
    this._name = name;
    this._age = age;
  }

  // getters and setters
  set name(name) {
    this._name = name;
  }
  get name() {
    return this._name;
  }
  set age(age) {
    this._age = age;
  }
  get age() {
    return this._age;
  }


  //methods

  addFriend(friend) {
    this._friends.push(friend)
  }

  sendMessage(message, friend) {
    this._messages.push(message)
    friend._messages.push(message)
  }

  showMessages() {
    return this._messages;
  }

}

Mi soluci贸n:
.
.
.
.
.
.
.
.
.
.

export class User {
  constructor(name, age) {
    this._name = name
    this._age = age
    this._friends = []
    this._messages = []
  }

  get name() {
    return this._name
  }

  set name(newName) {
    this._name = newName
  }

  get age() {
    return this._age
  }

  set age(newAge) {
    this._age = newAge
  }

  addFriend(friend) {
    if (friend instanceof User)
      this._friends.push(friend)
  }

  sendMessage(message, friend) {
    if (this._friends.some(friends => friends.name === friend.name))
      this._messages.push(message)
      friend._messages.push(message)
  }

  showMessages() {
    return this._messages
  }
}

considero la siguiente parte de la guia poco especifica
agrega un mensaje a la lista de mensajes del usuario actual y al amigo especificado.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
Mi solucion:

export class User {
  _name;
  _age;
  _friends = [];
  _messages = [];

  constructor(name, age) {
    this._name = name;
    this._age = age;
  }

  addFriend(friend){
    this._friends.push(friend);
  }
  sendMessage(message, friend){
    this._messages.push(message);
    friend._messages.push(message);
  }
  showMessages(){
    return this._messages;
  }
  set name(newName) {
    this._name = newName;
  }
  get name() {
    return this._name;
  }
  set age(newAge) {
    this._age = newAge;
  }
  get age() {
    return this._age;
  }

}

Mi soluci贸n:

export class User {
  constructor(name, age) {
    this._name = name
    this._age = age
    this._friends = []
    this._messages = []
  }
  get name() { return this._name }
  get age() { return this._age }
  set name(name) { this._name = name }
  set age(age) { this._age = age }
  addFriend(friend) { this._friends.push(friend) }
  sendMessage(message, friend) {
    this._messages.push(message)
    friend._messages.push(message)
  }
  showMessages() { return this._messages }
}

Mi soluci贸n

No es un jefe, pero si fue interesante saber como usar el encapsulamiento dentro de JavaScript.
Cada d铆a los retos se ponen m谩s entretenidos ( 鈥⑻ 蠅 鈥⑻ )鉁
.
.
.

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }
  
  addFriend(friend) {
    this._friends.push(friend);
  }

  saveMessage(message) {
    this._messages.push(message);
  }

  sendMessage(message, friend) {
    this.saveMessage(message);
    friend.saveMessage(message);
  }
  showMessages() {
    return this._messages;
  }

  set name(name) {
    this._name = name;
  }
  get name() {
    return this._name;
  }

  set age(age) {
    this._age = age;
  }
  get age() {
    return this._age;
  }

}

ATENCI脫N: Si han llegado hasta aqu铆 para poder realizar este ejercicio deben pasar todos los m茅todos y propiedades al ingl茅s o no podr谩n correr los test.

Si se quieres ahorrar tiempo las propiedades son: name, age, friends y messages.

Los m茅todos son: addFriend, sendMessage y showMessages

Ahora mi soluci贸n:

.
.
.
.
.
.
.
.
.
.

export class User {
  constructor(name, age, friends= [], messages = []) {
    this._name = name
    this._age = age
    this._friends = friends
    this._messages = messages
  }

  addFriend(friend) {
    this._friends.push(friend)
  }

  sendMessage(message, friend) {
    this._messages.push(message)
    friend.messages = [...friend.messages, message]
  }

  showMessages() {
    return this._messages
  }

  get name() {
    return this._name
  }

  set name(newName) {
    this._name = newName
  }

  get age() {
    return this._age
  }

  set age(newAge) {
    this._age = newAge
  }

  get messages() {
    return this._messages
  }

  set messages(newMessages) {
    this._messages = newMessages
  }
}

MI SOLUCION 馃挭
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  get name() {
    return this._name;
  }

  set name(name) {
    this._name = name;
  }

  get age() {
    return this._age;
  }

  set age(age) {
    this._age = age;
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    this._messages.push(message);
    friend.receiveMessage(message);
  }

  receiveMessage(message) {
    this._messages.push(message);
  }

  showMessages() {
    return this._messages;
  }
}

Soluci贸n鈥 馃槃
.
Para el ejercicio, se debe implementar el constructor de la clase User y los m茅todos correspondientes al reto.
.
Se debe utilizar el car谩cter 鈥淿鈥 (antes del nombre de la propiedad) para proteger las propiedades de la clase.
.
NOTA: En el m茅todo sendMessage(message, friend) se refiere a que ambos usuarios deben agregar el mensaje a su correspondiente lista de mensajes.
.
C贸digo:
.

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    this._messages.push(message);
    friend._messages.push(message);
  }

  showMessages() {
    return this._messages;
  }

  get name() {
    return this._name;
  }

  set name(newName) {
    this._name = newName;
  }

  get age() {
    return this._age;
  }

  set age(newAge) {
    this._age = newAge;
  }
}

El problemita que me demor贸 un poquito de este ejercicio, fu茅 en el env铆o del mensaje rec铆proco al friend, aunque creo que en un sistema real, el env铆o de este mensaje deber铆a realizarse fuera del scope de del cualquier objeto.
Aqu铆 mi soluci贸n:

export class User {
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }
  get name() {
    return this._name;
  }
  set name(newName) {
    if (newName != "")
      this._name = newName;
    else
      console.log("El nombre no puede ser un string vac铆o");
  }

  get age() {
    return this._age;
  }
  set age(newAge) {
    if (newAge > 0)
      this._age = newAge;
    else
      console.log("La edad debe ser un valor mayor a cero");
  }
  get messages() {
    return this._messages;
  }
  set messages(message) {
    this._messages.push(message);
  }
  addFriend(friend) {
    this._friends.push(friend);
  }
  sendMessage(message, friend) {
    this._messages.push(message);
    friend.messages = message;
  }
  showMessages() {
    return this._messages;
  }
}

Hola, dejo mi solucion
Caminito anti spoilers
馃洿鉁
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Llegamos 馃搷

export class User {
  // Tu c贸digo aqu铆 馃憟
  constructor(name, age, friends = [], messages = []) {
    this._name = name;
    this._age = age;
    this._friends = friends;
    this._messages = messages;
  }
  addFriend(friend) {
    this._friends.push(friend)
  }
  sendMessage(message, friend) {
    this._messages.push(message);
    friend._messages.push(message)
  }
  showMessages() {
    return this._messages;
  }
  get name() {
    return this._name;
  }
  set name(newName) {
    this._name = newName;
  }
  get age() {
    return this._age;
  }
  set age(newAge) {
    this._age = newAge;
  }
}

MI soluci贸n:

class User {
  constructor(name,age,friends=[],messages=[]){
    this._name=name;
    this._age=age;
    this._friends=friends;
    this._messages=messages;
  };
  addFriend(friend){
    this._friends.push(friend);
  };
  sendMessage(message, friend){
    this._messages.push(message)
    return friend._messages.push(message)
  };
  showMessages(){
    return this.messages;
  };

  get name(){
    return this._name;
  };

  set name(newName){
    this._name=newName;
  };


  get age(){
    return this._age;
  };

  set age(newAge){
this._age=newAge;
  };

  get friends(){
    return this._friends;
  };

  set friends(newFriend){
    addFriend(newFriend);
  };


  get messages(){
    return this._messages;
  };

  set messages(newMessage){
    
    sendMessage(newMessage, friend);
    
  };
}

Dejo mi soluci贸n:

export class User {
  // Tu c贸digo aqu铆 馃憟
  constructor(name, age, friends, messages) {
    this._name = name,
      this._age = age,
      this._friends = [],
      this._messages = []
  };

  get name() {
    return this._name
  };

  set name(newName) {
    this._name = newName
  };

  get age() {
    return this._age
  };

  set age(newAge) {
    this._age = newAge
  };

  get friends() {
    return this._friends;
  };

  set friends(newFriends) {
    this._friends = newFriends
  };

  get messages() {
    return this._messages;
  };

  set messages(newMessages) {
    this._messages = newMessages
  };


  addFriend(friend) {
    this.friends.push(friend)
  };

  sendMessage(message, friend) {

    this.messages.push(message);

    for (let i = 0; i < this.friends.length; i++) {

      if (this.friends[i].name === friend.name) {

        this.friends[i].messages.push(message)

      }

    };

  };

  showMessages() {
    return this._messages
  }
}

Mi solucion:
.
.
.
.
.
.
.
.
.
.
.

export class User {
constructor(name, age, friends = [], messages = []) {
this._name = name;
this._age = age;
this._friends = friends;
this._messages = messages;
}
get age() { return this._age; }

get name() { return this._name }

set age(age) {
if (age > 0) {
this._age = age
}
}

set name(name) {
this._name = name;
}

addFriend(friend) { this._friends.push(friend) }

sendMessage(message, friend) {
this._messages.push(message);
friend._messages.push(message)
}

showMessages() {
return this._messages;
}
}

Soluci贸n.

export class User {
  // Tu c贸digo aqu铆 馃憟
  constructor(name, age) {
    this._name = name;
    this._age = age;
    this._friends = [];
    this._messages = [];
  }

  set name(newName) {
    if (newName === "")
      console.log("El nombre no puede estar vac铆o");
    else
      this._name = newName;
  }

  get name() {
    return this._name;
  }

  set age(newAge) {
    if (newAge === "")
      console.log("La edad no puede estar vac铆a");
    else
      this._age = newAge;
  }

  get age() {
    return this._age;
  }

  set message(newMessage) {
    if (newMessage === "") {
      console.log("No existe el mensaje");      
    } else {
      this._messages.push(newMessage);
    }
  }

  addFriend(friend) {
    this._friends.push(friend);
  }

  sendMessage(message, friend) {
    this._messages.push(message);
    friend.message = message;
  }

  showMessages() {
    return this._messages;
  }
}

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

export class User {
  // Tu c贸digo aqu铆 馃憟
  constructor(nombre, edad) {
    this._name = nombre
    this._age = edad
    this._friends = []
    this._messages = []
  }

  set name(nombre) {
    this._name = nombre
  }

  get name() {
    return this._name
  }

  set age(age) {
    this._age = age
  }

  set message(message) {
    this._messages.push(message)
  }

  get age() {
    return this._age
  }

  addFriend(friend) {
    this._friends.push(friend)
  }

  sendMessage(message, friend) {
    this._messages.push(message)
    friend.message = message
  }

  showMessages() {
    return this._messages
  }
}
undefined