Logo LIBR
Halo

Portfolio

Back to Blog
4 min read
JS Module 3 — SolutionsJan 2026

Array & Object — Solutions

JavaScript, Array, Object, Solutions
Syifa Fauziyah Arizal

Official solutions for Module 3 challenges. If you didn't try first — scroll back.

These are the official solutions for the Module 3 challenges. Compare them with your own answers and focus on understanding the data flow, not just the syntax.

Challenge 1 — Filter Students (score > 80)

JavaScript
let students = [
  { name: "Adit", score: 85 },
  { name: "Bela", score: 92 },
  { name: "Ciko", score: 70 }
];

let passedStudents = students.filter(s => s.score > 80);
console.log(passedStudents);

Why filter?
Because you're selecting data, not transforming it.

Challenge 2 — Increase Prices by 10%

JavaScript
let products = [
  { name: "Keyboard", price: 150000 },
  { name: "Mouse", price: 80000 },
  { name: "Headset", price: 200000 }
];

let updatedProducts = products.map(p => {
  return {
    ...p,
    price: p.price * 1.1
  };
});

console.log(updatedProducts);

Key insight:
map() returns a new array. We keep data immutable like real developers.

Challenge 3 — Get Admin Users

JavaScript
let users = [
  { name: "Syfa", role: "admin", active: true },
  { name: "Rizal", role: "user", active: false },
  { name: "Dina", role: "admin", active: true }
];

let admins = users.filter(u => u.role === "admin");
console.log(admins);

This pattern shows up constantly in dashboards, permission systems, and API filtering.

Bonus — Active Admins Only

JavaScript
let activeAdmins = users.filter(
  u => u.role === "admin" && u.active
);

console.log(activeAdmins);

Combining conditions is a very common real-world filtering pattern.

Final Notes

  • Use filter() to select data
  • Use map() to transform data
  • Avoid mutating original arrays
  • Most UI bugs start with bad data handling

More to read