Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
El filtro de JavaScript debería devolver matrices si la identificación coincide

Tengo datos de libros. Me gustaría devolver los libros si coinciden con la identificación del autor. Cuando trato de filtrar datos que no coinciden con mi identificación de 'autor'. Sin embargo, siempre devuelve todos los datos del libro.

 const author = "AUTHOR#e9bb9d29-7f20-4fce-892c-6a155dbee42c"; const Book = [ { publishingYear: "2020", rating: 5.2, GSI1SK: "AUTHOR#a731ea70-f3f3-4811-9734-f22c0856385d", genre: ["adventure", "drama", "scifi"], GSI1PK: "AUTHOR", page: 100, publisher: "Afternoon pub", SK: "BOOK#c4a58f20-4977-4db8-9723-0185f68cdf01", price: "3.50", PK: "BOOKS", author: "Krishna", title: "Me and mySelf" }, { publishingYear: "2020", rating: 5.2, GSI1SK: "AUTHOR#6b7c10ff-0e2c-46bd-9697-3b51730d8b29", genre: ["adventure", "drama", "scifi"], GSI1PK: "AUTHOR", page: 100, publisher: "Day pub", SK: "BOOK#e4773a32-5451-42c6-a3f1-a6aa45176256", price: "3.50", PK: "BOOKS", author: "John doe", title: "Hello world" }, { publishingYear: "2020", rating: 5.2, GSI1SK: "AUTHOR#a731ea70-f3f3-4811-9734-f22c0856385d", genre: ["adventure", "drama", "scifi"], GSI1PK: "AUTHOR", page: 100, publisher: "Night Pub", SK: "BOOK#fb56a876-41bc-49f9-9762-c48e90af3117", price: "3.50", PK: "BOOKS", author: "Krishna", title: "Amazing Race" } ]; const Books = Book.filter((i) => { console.log(i.GSI1SK); i.GSI1SK === author; return i; }); console.log(Books);

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Está utilizando el filtro de manera incorrecta, debe devolver verdadero o falso según la condición que está haciendo coincidir,

 const Books = Book.filter((i) => { console.log(i.GSI1SK); return i.GSI1SK === author; });
about 4 years ago · Juan Pablo Isaza Report

0

Y puedes omitir líneas innecesarias. Prueba esto.

 const Books = Book.filter(i => i.GSI1SK === author)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!