ควิซ JavaScript: map, filter & reduce

This JavaScript quiz checks how well you know the array methods you use every day. You will predict what map(), filter(), reduce(), find() and forEach() return and catch the traps that bite beginners, like a missing return or reduce() on an empty array.

ปานกลาง 10 ข้อ ~6 นาที ผ่านที่ 80% Node.js 22

เลือกโหมด

กำลังเล่นแบบผู้เยี่ยมชม: เข้าสู่ระบบเพื่อเก็บ XP และ streak

ตัวอย่างคำถาม

ข้อ 1 จาก 10

What does this print?

const nums = ["1", "2", "3"].map(parseInt);
console.log(nums.join(" "));
ดูเฉลย

B. 1 NaN NaN map() calls the callback with (item, index, array), so parseInt gets the index as its radix: parseInt('2', 1) and parseInt('3', 2) are NaN. Write .map(s => parseInt(s, 10)) or .map(Number) instead.

ควิซนี้มีเนื้อหาอะไรบ้าง

  • What map() and filter() return, and what their callbacks receive
  • reduce() with and without an initial value
  • find() vs filter() vs forEach()
  • Chaining array methods
  • Arrow function bodies that forget to return

คำถามที่พบบ่อย

ต้องมีบัญชีไหม?

ไม่ต้อง ใครก็เล่นได้ เข้าสู่ระบบเพื่อเก็บ XP, streak, เหรียญตรา และประวัติ

ทำซ้ำได้ไหม?

ได้ ระบบเก็บคะแนนที่ดีที่สุดไว้ และสลับคำถามกับตัวเลือกใหม่ทุกครั้ง