¡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 - agrupa los productos

43/99

Aportes 84

Preguntas 0

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

🛡️Escudo anti-spoilers🛡️

Mi solucion:

export function groupProducts(products, category) {
  const res = {}

  //Productos que cumple con la categoria
  const category_products = products.filter(x => x.category == category)

  res['products'] = category_products.map(x => x.name).join(", ")
  res['totalPrice'] = category_products.reduce(((acum, { price }) => acum + price), 0)


  return res
}

Con ayuda de la programación funcional y el curso de manejo de arrays de NicoBytes.

export function groupProducts(products, category) {
  // Filtrar los produtos
  const products1 = products.filter(prod => prod.category === category);
  // Nombre de los productos separados por comas en orden
  const prodName = products1.map(prod => prod.name).join(', ');
  // Suma de los precios de productos de la categoría
  const sumPrices = products1.map(prod => prod.price).reduce((sum, curr) => sum + curr);

  return {
    products: prodName,
    totalPrice: sumPrices
  }
}

o estoy aprendiendo o este estaba fácil

🛡️🛡️Escudo anti-spoilers🛡️🛡️

Mi solución al reto

export function groupProducts(products, category) {
    let groupProducts = "";
    let totalPrice = 0;
  
    for (let product of products) {
      if (category === product.category) {
        groupProducts += (groupProducts.length > 0) ? `, ${product.name}` : `${product.name}`;
        totalPrice += product.price
      }
    }
  
    return {
      products: groupProducts,
      totalPrice: totalPrice
    }
}  
export function groupProducts(products, category) {
  let names = [];
  let sum = 0;
  products.forEach(product => {
    if (product.category === category) {
      names.push(product.name);
      sum += product.price;
    }
  });
  return {
    products: names.join(", "),
    totalPrice: sum
  }
}

solucion

export function groupProducts(products, category) {
  let arrayFilter = {};
  let acountPrice = 0;
  let acountName = [];


  products.forEach(element => {
    if (element.category === category) {
      //console.log(element);

      acountName.push(element.name);
      acountPrice += element.price;
    }
  });
  arrayFilter.products = acountName.join(", ");
  arrayFilter.totalPrice = acountPrice;
  return arrayFilter;
}

🛡️Escudo anti-spoilers🛡️

tal vez está poco entendible pero ahi esta, si alguien tiene duda se lo puedo explicar

export function groupProducts(products, category) {
  // Tu código aquí
  return {
    products:
      products.filter(obj => obj.category === category)
              .map(obj => obj.name).join(", "),
    totalPrice:
      products.filter(obj => obj.category === category)
              .map(obj => obj.price)
              .reduce((acc, cur) => acc + cur, 0),
  };
}

Escudo anti-spoilers 🛡️

Les comparto mi solucion. ```js export function groupProducts(products, category) { const newProduct = { products: "", totalPrice: 0, }; const filtroProducts = products.filter(product => product.category === category); const filtroNames = filtroProducts.map(product => product.name); const namesProducts = filtroNames.join(", "); newProduct.products = namesProducts; const filtroPrice = filtroProducts.map(product => product.price) const sumaPrice = filtroPrice.reduce((acumulador, price) => acumulador + price); newProduct.totalPrice = sumaPrice; return newProduct; } ```function groupProducts(products, category) {    const newProduct = {        products: "",        totalPrice: 0,    };        const filtroProducts = products.filter(product => product.category === category);    const filtroNames = filtroProducts.map(product => product.name);    const namesProducts = filtroNames.join(", ");    newProduct.products = namesProducts;     const filtroPrice = filtroProducts.map(product => product.price)    const sumaPrice = filtroPrice.reduce((acumulador, price) => acumulador + price);    newProduct.totalPrice = sumaPrice;       return newProduct;}
export function groupProducts(products, category) {
  const filteredProducts = products.filter(product => product.category === category);

  const productNames = filteredProducts.map(product => product.name).join(", ");
  const totalPrice = filteredProducts.reduce((sum, product) => sum + product.price, 0);

  return {
    products: productNames,
    totalPrice: totalPrice,
  };
}

🛡️Escudo anti-spoilers🛡️
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  // Tu código aquí
  console.log(category);
  if (category) {
    const filteredProducts = products.filter((product) => product.category === category);
    console.log(filteredProducts);
    let productResult = filteredProducts.reduce((acum, product) =>
      (acum + product.name + ', '), '');

    return {
      products: productResult.slice(0, -2),
      totalPrice: filteredProducts.reduce((acum, product) => 
        (acum + product.price), 0)
    }
  }
}

Solución! 😄

🛡️🛡️🛡️Escudo anti spoilers🛡️🛡️🛡️

Agrupa los productos

export function groupProducts(products, category) {
  // Tu código aquí
  let totalPrice = 0;
  let productsName = [];
  products.forEach((element) => {
    if (element.category == category) {
      totalPrice += element.price;
      productsName.push(element.name);
    }
  });
  return { products: productsName.join(", "), totalPrice };
}

Mi solución

function groupProducts(products, category) {
  const bill = {
    products,
    totalPrice: 0
  }
  const productNames = []
  const productsByCategory = products.filter(product => product.category === category);
  productsByCategory.forEach(product => productNames.push(product.name));
  bill.products = productNames.join(', ');
  bill.totalPrice = productsByCategory.reduce((a, b) => a.price + b.price)
  return bill;
}
export function groupProducts(products, category) {
  const productFilteredData = products
    .filter(p => p.category === category)
    .map(p => ({ name: p.name, price: p.price }))
  return {
    products: productFilteredData.map(p => p.name).join(', '),
    totalPrice: productFilteredData.reduce((acc, item) => acc + item.price, 0)
  }
}
export function groupProducts(products, category) {
  // Tu código aquí
  let productByCategory = products.filter(product => product.category === category);

  let productNames = products.map(product => product.name).join(', ');
  let totalPrice = product.map(product => product.price).reduce((previusValue, currentValue) => previusValue + currentValue);
  let result = {
    products: productNames,
    totalPrice = totalPrice
  }
  return result;
}

Comparto mi solución:

.
.
.
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  // Tu código aquí
  const result = {};
  const targetCategory = products.filter(function (product) {
    return product.category === category;
  });
  
  result.products = targetCategory.map(product =>
    product.name).join(", ");
  
  result.totalPrice = targetCategory.reduce(((acum, { price }) => acum + price), 0)
  
  return result;
}

Mi solución 💚

export function groupProducts(products, category) {
  let filteredProducts = products.filter((product) => product.category === category)

  return {
    products: filteredProducts.map((product) => product.name).join(', '),
    totalPrice: filteredProducts.reduce((total, actualProduct) => total + actualProduct.price, 0)
  }
}


.
.
.
.
.
.

export function groupProducts(products, category) {
    const filterProducts = products.filter(product => product.category === category);
    let output = {
        products: '', 
        totalPrice: 0
    }
    let nameProducts = [];
    filterProducts.forEach(product => { 
        nameProducts.push(product.name);
        output.totalPrice += product.price;
    })
    const totalProducts = nameProducts.join(', ');
    output.products += totalProducts;

    return output;
}  

Mi solución:

export function groupProducts(products, category) {
  const filteredByCategory = products.filter((product) => product.category === category);

  return {
    products: filteredByCategory.map(({name}) => name).join(', '),
    totalPrice: filteredByCategory.reduce((total, product) => total + product.price, 0),
  };
}
export function groupProducts(products, category) {
  let obj = {}
  const resultFilter = products.filter(product => product.category === category)
  obj['products'] = resultFilter.map(pro => pro.name).join(', ');
  obj['totalPrice'] = resultFilter.map(pro => pro.price).reduce((total, valor) => total + valor, 0);
  return obj;
}
function groupProducts(products, category) {
  let product = new Array()
  let sum = 0

  products.forEach(element => {
    if (element.category == category) {
      product.push(element.name)
      sum += element.price
    }
  });

  // imprimir el objeto
  console.log({
    products: product.join(", "),
    totalPrice: sum
  })
}

MI Solución:


export function groupProducts(products, category) {
  let totalPrice = 0;
  let productName = []
  products.map(product => {
    if (product.category === category) {
      productName.push(product.name);
      totalPrice += product.price;
    }
  });
  products = productName.join(", ");
  return { products, totalPrice }
}


sin usar programación funcional, lo siento, pero aun me cuesta usar las funciones anónimas y flecha. Pero funciona.

export function groupProducts(products, category) {
  // Tu código aquí
  let productos = ''
  let total = 0
  for (const [key, value] of Object.entries(products)) {
    if (value.category == category) {
      total += value.price
      productos += value.name + ', '
    }
  }
  productos = productos.slice(0, -2);
  return { products: productos, totalPrice: total }  
}

Mi solución al reto.

export function groupProducts(products, category) {
  // Tu código aquí
  let filterProducts = []
  let total = 0

  products.forEach(e => {
    if (e.category === category) {
      filterProducts.push(e.name)
      total += e.price
    }
  })

  return {
    products: filterProducts.join(", "),
    totalPrice: total
  }
}

comparto mi solución al reto

export function groupProducts(products, category) {
  const filteredProducts = products.filter(product => product.category == category)
  //console.log(filteredProducts);
  const totalPrice = filteredProducts.reduce((acumulator, currentValue) => acumulator += currentValue.price, 0)
  //console.log(totalPrice);
  const productsName = filteredProducts.map(product => product.name)
  //console.log(productsName);

  const joinName = productsName.join(', ')
  const data = {
    products: joinName,
    totalPrice: totalPrice
  }
  //console.log(data);
  return data;
}
export const groupProducts = (products, category) => {
  const group = products.filter(product => product.category === category);

  return {
    'products': group.map(product => product.name).join(', '),
    'totalPrice': group.reduce((total, product) => total + product.price, 0)
  }
}

dejo mi solucion por aqui
.
.
.
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  // Tu código aquí
  const productos = products.filter(el => el.category === category);
  const productsPrices = [];
  const productNames = [];
  productos.forEach(el => {
    productsPrices.push(el.price);
  });
  const totalPrice = productsPrices.reduce((a, b) => a + b, 0);

  productos.forEach(el => {
    productNames.push(el.name);
  });

  return {
    products: productNames.join(', '),
    totalPrice: totalPrice,
  };
}

Hola Comparto mi solución:

















export function groupProducts(products, category) {
  const findProducts = [];
  let totalPrice = 0;

  products.forEach((product) => {
    if (product.category === category) {
      findProducts.push(product.name);
      totalPrice += product.price;
    }
  });

  return {
    products: findProducts.join(", "),
    totalPrice: totalPrice,
  };
}

APORTE:


SPOILER

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

<code> 
export function groupProducts(products, category) {
  // Tu código aquí

  let arrayProducts = [];
  let price = 0;

    let filteredArray = products.filter(element => element.category==category)

  if (filteredArray.length > 0) {
    for (let element of filteredArray) {
      arrayProducts.push(element.name);
      price += element.price;
    }
    return { products: arrayProducts.join(", "), totalPrice: price };
  }
  else { 
    return null;
  }

Para el nivel de complejidad que tenían los ejercicios previos, me imaginé este mucho más difícil…

v
v
v
v
v
v
v
v
v
v
v
v

export function groupProducts(products, category) {
  let ProductOutput = []
  let totalPrice = 0
  products.forEach((product) => {
    if (product.category === category) {
      ProductOutput.push(product.name)
      totalPrice += product.price
    }
  })
  return {
    products: ProductOutput.join(', '),
    totalPrice: totalPrice
  }
}

function groupProducts(products, category) {
  // Tu código aqu

  const productsByCategory = products.filter(item => item.category === category)

  const object = {
    products: productsByCategory.map(item => item.name).join(", "),
    totalPrice: productsByCategory.reduce((acum, sum) => acum + sum.price, 0)
  }

  return object
}

.

my solution

.

export function groupProducts(products, category) {
  const result = products
    .filter((product) => product.category === category)
    .reduce((acc, prod) => {
      return {
        products: [...acc.products, prod.name],
        totalPrice: acc.totalPrice + prod.price
      }},
      {
        products: [],
        totalPrice: 0
      })
  return {
    products: result.products.join(', '),
    totalPrice: result.totalPrice
  }
}

Challenge exceeded

export function groupProducts(products, category) {
  // Tu código aquí
  let totalPrice = 0
  let productName = ''

  let productsByCategory = products.filter(product => product.category === category)

  for (let i of productsByCategory) {
    totalPrice += i.price
  }

  for (let i of productsByCategory) {
    if (!productName.length) {
      productName += `${i.name}`
    } else {
      productName += `, ${i.name}`
    }
  }

  return {
    products: productName,
    totalPrice
  }
}

🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️

export function groupProducts(products, category) {

  let listofproductsbycategory = [];
  let total = 0;
  products.map(eachProduct => {
    
    if (eachProduct.category === category) {
      listofproductsbycategory.push(eachProduct.name);
      total += eachProduct.price;
    }
  })
  return {
    products: listofproductsbycategory.join(', '),
    totalPrice: total

  }
}```

Solución

function groupProducts(products, category) {
  // Tu código aquí

  const filteredProducts = products.filter(product => category === product.category)
  const pNames = filteredProducts.map(prod => prod.name)
  const pPrices = filteredProducts.map(prod => prod.price).reduce((acc, cur) => acc + cur, 0)
  
  const queriedProducts = {
    products: pNames.join(", "),
    totalPrice: pPrices
  }

  console.log(queriedProducts)
  return queriedProducts
}

mi solucion aunque me falta refinarla un poco queria probar la logica de como no ingresar la coma y el espacio.

export function groupProducts(products, category) {
  let rta = { products: '', totalPrice: 0, };
  let k = products.filter(x => x.category === category).length;
  for (let index = 0; index < products.length; index++) {
    const element = products[index];
    if (element.category === category) {
      if (k != 1) {
        rta = { products: rta.products + element.name + ', ', totalPrice: rta.totalPrice + element.price };
        k--;
      } else {
        rta = { products: rta.products + element.name, totalPrice: rta.totalPrice + element.price };
      }
    }
  }
  return rta;
}

Cuidado Spoiler

Mi solucion

export function groupProducts(products, category) {
  const categoryProducts = products.filter(
    product => product.category === category
  )
  const categoryTotal = categoryProducts.reduce(
    (total, product) => total += product.price
    , 0)

  const productNames = categoryProducts.map(product => product.name).join(", ")

  return {
    products: productNames,
    totalPrice: categoryTotal
  } 
}

Cuando se le pilla el punto, esto de jugar con las funciones es muy potente
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  const prodCategoria = products.filter((item) => item.category == category);
  const names = prodCategoria.flatMap((item)=>item.name).join(", ");
  const totalPrice = prodCategoria.reduce((total, item) => total + item.price,0);
  return { products:names,totalPrice };
}

Buenas, comparto mi solucion, la verdad me siento muy orgulloso ya que lo realice sin necesidad de ninguna ayuda, me costo dure como tres horas pero al final lo logre, al final no me habia dado cuenta y le habia puesto una ‘s’ mas en el objeto de retorno al totalPrice jajajajaja, le comparto mi codigo:


Mi aporte

export function groupProducts(products, category) {
  // Tu código aquí
  let prods = "";
  let price = 0;
  products.forEach(el => {
    if (el.category === category) {
      prods = prods + el.name + ", ";
    price = price + el.price
    }
  });

  let result = {
    products: prods.trimEnd().slice(0, prods.length - 2),
    totalPrice: price
  }

  return result

}


















export function groupProducts(products, category) {
  let data = products.filter((element) => element.category === category);
  const totalPrice = data.reduce((suma, number) => suma.price + number.price);
  const productsName = data.reduce((array, elem) => {
    array.push(elem.name)
    return array
  },[]) 
  
  return { products: productsName.join(', '), totalPrice}
  
}

💢 💢 💢 ANTI SPOILER 💢 💢 💢

Mi respuesta.

export function groupProducts(products, category) {
  // Tu código aquí
  const groupProducts = {
    products: [],
    totalPrice: 0
  };
  products.forEach(product => {
    if (product.category == category) {
      groupProducts.products.push(product.name);
      groupProducts.totalPrice += product.price;
    }
  });

  groupProducts.products = groupProducts.products.join(", ");
  return groupProducts;
}

Solucion1. Metodos filter, map y reduce.

export function groupProducts(products, category) {
  const filtered = products.filter(product => product.category === category);
  return {
    products: filtered.map(product => product.name).join(", "),
    totalPrice: filtered.reduce((acc, val) => acc.price + val.price)
  }
}

Solucion 2. Metodo reduce + metodo concat:

    export function groupProducts(products, category) {
  return products.reduce((acc, val) => {
    if (acc.products === undefined) {
      acc.products = '';
      acc.totalPrice = 0;
    }
    if (val.category === category) {
      if (acc.products !== '') {
        acc.products = acc.products.concat(', ' + val.name);
      } else {
        acc.products = val.name;
      }
      acc.totalPrice += val.price;
    }
    return acc;
  }, {})
}
export function groupProducts(products, category) {
  // Tu código aquí
  let subTotal = 0;
  const items = [];
  const productByCategoria = products.filter((product) => {
    if (product.category === category) {
      items.push(product.name);
      subTotal += product.price;
      return true;
    }
  });
  return { products: items.join(', '), totalPrice: subTotal };
}

Comparto mi solución
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  // Tu código aquí
  const filtered = products.filter((p) => p.category === category)
  const totalPrice = filtered.reduce((a, p) => a + p.price, 0);
  const productsString = filtered.map(p => p.name).join(", ");
  return {
    products: productsString,
    totalPrice
  }

}

Linda la propuesta de devolver los productos como un string… 😃

export function groupProducts(productos, category) {
  // Tu código aquí

  const productsfilters = productos.filter(
    product => product.category === category)
    .reduce((acc, curr) => {

      if (acc.products.length === 0) {
        return {
          products: acc.products.concat(curr.name),
          totalPrice: acc.totalPrice + curr.price
        }
      } else {

        return {
          products: acc.products.concat(", ").concat(curr.name),
          totalPrice: acc.totalPrice + curr.price
        }

      }

    }, {
      products: "",
      totalPrice: 0,
    });


  return productsfilters;
};

mi solución:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
    // Tu código aquí
    const groupedProducts = {};
  
    const filteredProducts = products.filter(product => product.category === category);

    groupedProducts.products = filteredProducts.map(product => product.name).join(", ");
    groupedProducts.totalPrice = filteredProducts.map(product => product.price).reduce((acumulador, numero) => acumulador + numero);
  
    return groupedProducts;
}

Ez

export function groupProducts(products, category) {
  let output = {
    products: [],
    totalPrice: 0
  }

  products.map((item) => { 
    if (item.category == category) {
      output.totalPrice += item.price
      output.products.push(item.name)
    }
  })

  output.products = output.products.join(", ")
  return output;
}

Mi solucion:

export function groupProducts(products, category) {
  const arrayproductos = [];
  let total = 0;
  for (let i = 0; products.length > i; i++) { 
    const producto = products[i].name;


    if (category === products[i].category) { 
      arrayproductos.push(products[i].name);
      total = total + products[i].price;
    }
  }
  let nombreproducto = arrayproductos.join(", ")

  let result = {
    products: nombreproducto,
    totalPrice: total
  }

  return result;
}

Mi versión de la solución, con lo aprendido:

  let descripProducts = "";
  let totalPrice = 0;

  products.filter((value) => {
    if (value.category === category) {
      if (descripProducts === "") {
        descripProducts = value.name;
      } else {
        descripProducts = `${descripProducts}, ${value.name}`;
      }
      totalPrice = totalPrice + value.price;
      return value;
    }
  });

  return (products = {
    products: descripProducts,
    totalPrice: totalPrice,
  }); 

MI SOLUCION 💪
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  const producstByCategoty = products.filter(product => product.category === category);
  const nameProducts = producstByCategoty.map(product => product.name).join(", ");
  const totalPrice = producstByCategoty.reduce((total, product) => total + product.price, 0);
  return {
    products: nameProducts,
    totalPrice
  };
}

Esta es mi solución, cuidado con los spoilers:
.
.
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  let totalPrice = 0;
  let pNameArray = [];

  let selectedProducts = products.filter(item => item.category === category);

  selectedProducts.forEach(item => {
    totalPrice += item.price;
    pNameArray.push(item.name);
  });

  let auxPName = pNameArray.join(", ");
  return { "products": auxPName, "totalPrice": totalPrice };
}

Mi solución:

export function groupProducts(products, category) {
  let output = {
    products: "",
    totalPrice: 0
  }
  const filteredProducts = products.filter((product) => product.category === category)

  output.products = filteredProducts.map(({ name }) => name).join(", ")

  filteredProducts.forEach((product) => output.totalPrice += product.price)

  return output
}

estaba facil

export function groupProducts(products, category) {
  const filteredByCategory = products.filter(item => item.category == category)
  const names = filteredByCategory.map(item => item.name).join(', ')
  const suma = filteredByCategory.reduce((a, b) => a + b.price, 0)

  return { products: names, totalPrice: suma }
} 

++
+
+
+
+
++
+
+

export function groupProducts(products, category) {
  let productsFilter = products.filter((product) => {
    return product.category === category;
  })
  let productos = {
    products: "",
    totalPrice: 0
  }
  let nameProducts = [];
  for (const [key, value] of Object.entries(productsFilter)) {
    nameProducts.push(value.name);
    productos.totalPrice += value.price;
  }
  productos.products = nameProducts.join(", ");
  return productos;
}

Aquí mi solución usando un for in:

export function groupProducts(products, category) {
  let totalPrice = 0;
  var prod = [];
  const result = products.filter(prod => prod.category === category);
  for (const prop in result) {
    prod.push(result[prop].name);
    totalPrice += result[prop].price;
  }
  return { products: prod.join(", "), totalPrice };
}

🛡️Escudo anti-spoilers🛡️

export function groupProducts(products, category) {
  return {
    products: products.filter(item => item.category === category).map(item => item.name).join(', '),
    totalPrice: products.filter(item => item.category === category).reduce((a, c) => a + c.price, 0)
  };
}


Solu
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

function groupProducts(products, category) {

const selectedProducts = products.filter(product => product.category === category);
let selectedNames = [];
let sumatoryOfPrices = 0;

for(let i=0; i<selectedProducts.length; i++){
selectedNames.push(selectedProducts[i].name);
sumatoryOfPrices = sumatoryOfPrices + selectedProducts[i].price;
};

return {
products: selectedNames.join(", "),
totalPrice: sumatoryOfPrices
}
}

Aquí mi solución:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

<export function groupProducts(products, category) {
  //filtro los productos segun la cateoria en productsCategory
  let productsCategory = products.filter(item => item.category == category);
  //sumo el precio de los productos filtrados
  let sumtotal = productsCategory.reduce((sum, item) => sum + item.price, 0);
  //obtengo el name de los productos filtrados en productoName
  let productsName = productsCategory.map((item) => item.name).join(', ');
  return { products: productsName, totalPrice: sumtotal };
}> 

the sol guys:

export function groupProducts(products, category) {
  const filteredproducts = products.filter(item => item.category === category);
  let result = {products: "", totalPrice: 0};
  for (const product of filteredproducts) {
    if (result.products == "") {
      result.products = result.products.concat('', product.name);
    } else {
      result.products = result.products.concat(', ', product.name);
    }
    result.totalPrice += product.price;
  }
  return result;
}

Hola, aqui mi solución. Use el metodo filter y un simple bucle for of
.
.
.
.
.
.
.

function groupProducts(products, category) {
  const filteredProducts = products.filter((product) => product.category == category)
  const names = []
  let totalPrice = 0
  for (let product of filteredProducts) {
    names.push(product.name)
    totalPrice += product.price
  }
  return { products: names.join(", "), totalPrice }
}

Hola! aquí mi solución 😀
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.

export function groupProducts(products, category) {
  // Tu código aquí
  const filteredProducts = products.filter((product) => product.category === category)
  return {
    products: filteredProducts.map((product) => product.name).join(', '),
    totalPrice: filteredProducts.reduce((acum, product) => acum + product.price, 0)
  }

}
export function groupProducts(products, category) {
  // Tu código aquí
  const filteredProducts = products.filter(product => product.category === category)

  const mappedProducts = filteredProducts.map(product => product.name)

  const totalPrice = filteredProducts.reduce((acc, curr) => acc + curr.price, 0) 

  return {
      products: mappedProducts.join(", "),
      totalPrice
  }
}

.
.
.
.
.
.
.
.
.
Mi solución solo con reduce

export const groupProducts = (products,category,) =>
  products.reduce(
    (obj, product) => {
      if (product.category === category) {
        obj["totalPrice"] = obj["totalPrice"] + product.price;
        obj["products"] = (!obj["products"])
          ? product.name
          : obj["products"].concat(`, ${product.name}`);
      }
      return obj;
    },
    { products: "", totalPrice: 0 },
  );

SPOILLLLLLLLEER
.
.
.
.
.
.
.
.
.

  const productsByCategory = products.filter(
    (product) => product.category === category
  );

  const productsName = productsByCategory
    .map((product) => product.name)
    .join(', ');

  const totalPrice = productsByCategory.reduce(
    (acum, product) => acum + product.price,
    0
  );

  return {
    products: productsName,
    totalPrice,
  };

Mi solución
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  const productsByCategory = [];
  let totalPrice = 0;

  products
    .filter((product) => {
      return product.category === category;
    })
    .map((product) => {
      productsByCategory.push(product.name);
      totalPrice += product.price;
    });

  return {
    products: productsByCategory.join(", "),
    totalPrice: parseInt(totalPrice),
  };
}

Solución… 😄
.
Un reto bastante divertido, primero filtramos los productos por su categoría mediante la función filter().
.
Luego, creamos un array con únicamente los nombres de los productos filtrados, utilizando map() y la función join(", ") que nos devolverá una cadena con los productos separados por ", ".
.
Finalmente, acumulamos el precio de los productos filtrados en una variable mediante reduce(), y retornamos un objeto con las propiedades correspondientes.
.

export function groupProducts(products, category) {
  // Filtramos por categoría
  let filtered = products.filter((product) => product.category === category);

  // Creamos un array con los nombres de los fittrados
  let productNames = filtered.map((product) => product.name).join(", ");

  // Accumulamos el precio total de los filtrados
  let price = filtered.reduce((acc, product) => {
    return acc + product.price;
  }, 0);

  // Retornamos el objeto
  return {
    products: productNames,
    totalPrice: price
  };

}

Mi Solución
*
*
*
*
*
*
*

export function groupProducts(products, category) {
 
  const filteredProducts = products.filter(prod => prod.category === category)

  const productNames = filteredProducts.map(prod => prod.name).join(', ')

  const totalPrice = filteredProducts.reduce((acc,cur) => acc + cur.price, 0)

  return {
    products: productNames,
    totalPrice
  }
}

¡Hola, Desafío cumplido 😃!
Mi solución,
Se detalla hasta abajo.⬇








export function groupProducts(products, category) {
  const even = (element) => element.category === category;
  const filterByCategory = products.some(even);

  let rta = { products: "", totalPrice: 0 };
 

  if (filterByCategory) {
    const myList = products.filter(even);
    const myNames = myList.map(item => item.name);
    rta.products = myNames.join(", ");
    rta.totalPrice= myList.reduce(
      (accumulator, currentValue) => accumulator + currentValue.price, 0
    );

  }
  return rta;
}

Aquí dejo mi solución usando los métodos de los contenidos. Espero les ayude:

export function groupProducts(products, category) {
  // Tu código aquí
  let reply = {
    products: "",
    totalPrice: 0,
  }

  let categories = products.map(element => element.category)
  if (categories.includes(category)) {
    let matchedProducts = products.filter(product => product.category == category)
    let matchedProductsNameList = []
    matchedProducts.forEach(product => {
      reply.totalPrice += product.price
      matchedProductsNameList.push(product.name)
    });
    reply.products = matchedProductsNameList.join(", ")
  }

  return reply
}

Mi solución
.
.
.
.
.
.

export function groupProducts(products, category) {
  let total_products = { products: '', totalPrice: 0 };
  let product_list_name = [];
  let products_find = products.filter(product => {
    return product.category == category;
  });
  products_find.forEach(product => {
    product_list_name.push(product.name);
    total_products.totalPrice += product.price;
  })
  total_products.products = product_list_name.join(', ');
  return total_products;
}

.
.
.
.
.
.
.

export function groupProducts(products, category) {
  // Tu código aquí
  let nameProduct = [];
  let totalPrice = 0;
  products.forEach(product => {
    if (product.category === category) {
      nameProduct.push(product.name);
      totalPrice += product.price
    }
  });

  return {products: nameProduct.join(', '), totalPrice: totalPrice}
}

.
.

.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.

Mi solucion :3

export function groupProducts(products, category) {
  let outProducts = products.reduce((acc, curr) => {
    if (curr.category == category) {
      acc.products.push(curr.name)
      acc.totalPrice += curr.price
    }
    return acc
  }, { products: [], totalPrice: 0 })

  outProducts.products = outProducts.products.join(', ')
  return outProducts
}

Solución n.n

.
.
.
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
    let totalPrice = 0
    let productsFilter = products.filter(product => {
    if (product.category === category) {
            totalPrice += product.price
            return true
        }
        return false
    }).map(product => product.name)
    
    return {
        products: productsFilter.join(', '),
        totalPrice
    }
}

MI solución:

Curiosa la pequeña trampilla del espacio jajaja,o bueno, para mi fue curiosa:

export function groupProducts(products, category) {
  const categoria = products.filter((a) => a.category == category);
  const producto = categoria.map((a) => a.name);
  const total = categoria.reduce((a, b) => a.price + b.price);
  return {
    products: producto.join(", "),
    totalPrice: Number(total),
  };
}

Hola, dejo mi solucion
Caminito anti spoilers
🚗
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Llegamos 📍

const productsCategory = products.filter((product) => product.category === category)
    const productsName = productsCategory.map((product) => product.name)
    const productsSum = productsCategory.reduce((acumulador, numero) => (acumulador + numero.price), 0);
    return {
        products: productsName.join(', '), 
        totalPrice: productsSum
    }

Solución

export function groupProducts(products, category) {
  // Tu código aquí
  let productsByCategory = [];
  let totalPrice = 0;
  products.forEach(product => {
    if (product.category === category) {
      productsByCategory.push(product.name);
      totalPrice += product.price;
    }
  });
  return {
    products: productsByCategory.join(", "),
    totalPrice: totalPrice
  }
}

Adjunto mi solución:
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {
  const productsPerCategory = []
  let totalPrice = 0
  products.forEach(product => {
    if (product.category.includes(category)) {
      productsPerCategory.push(product.name)
      totalPrice += product.price
    }
  })
  return {
    products: productsPerCategory.join(', '),
    totalPrice
  }
}
export function groupProducts(products, category) {

  let sortProducts = [];
  let total = 0;

  for (let product of products) {

    if (product.category === category) {
      sortProducts.push(product.name);
      total += product.price;
      }
    
  }

  return {
    products: sortProducts.join(", "),
    totalPrice: total,
  }

 
}

Mi aporte:
.
.
.
.
.
.
.
.
.
.
.

function groupProducts(products, category) {

    let myProducts = [];
    let prices = [];

    products.forEach(element => {
        if(element.category === category){
            myProducts.push(element.name);
            prices.push(element.price);
        }        
    });
    let total = prices.reduce((sum, num) => sum + num, 0);

return {"products": myProducts.join(", "), totalPrice: total}
 
};

Alerta Spoiler
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {

  const categoryFilter = products.filter(prod => prod.category === category);

  const products = categoryFilter.reduce((a, b) => `${a.name}, `.concat(b.name));

  const totalPrice = categoryFilter.reduce((a, b) => a.price + b.price);

  return ({
    products,
    totalPrice
  })
}

Aporto mi solución
.
.
.
.
.
.
.
.
.
.
.
.

export function groupProducts(products, category) {

  //Creo un arreglo de productos y declaro e inicializo sumaPrecios en 0
  let cadenaProductos = []
  let sumaPrecios = 0

  //Compruebo todos los productos que coincidan con la categoría que recibí como parámetro y los que coinciden los agrego a cadenaProductos que por el momento es un array y agrego su precio a sumaPrecios
  products.forEach(producto => {
    if (producto['category'] === category) {
      cadenaProductos.push(producto['name'])
      sumaPrecios+=producto['price']
    }
  })

  //Una vez que filtré todos los productos los convierto en un string con el método join
  cadenaProductos = cadenaProductos.join(', ')
  
  return {
    products: cadenaProductos,
    totalPrice: sumaPrecios
  }
}

Spoiler:
.
.
.
.
.
.
.
.
.
.

function groupProducts(products, category) {
    const names = products
    .filter(prod => prod.category === category)
    .reduce((a, b) => `${a.name}, ${b.name}`);

    const prices = products
    .filter(prod => prod.category === category)
    .reduce((a, b) => a.price + b.price);

    return{
        products: names, 
        totalPrice: prices
    };
};
undefined