Quiz di 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.

Medio 10 domande ~6 minuti Superato con il 80% Node.js 22

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 10

What does this print?

const nums = ["1", "2", "3"].map(parseInt);
console.log(nums.join(" "));
Mostra la risposta

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.

Cosa copre questo quiz

  • 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

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.