- Esecutori
-
Impara
Impara Python Esempi eseguibili, NumPy, pandas e altro Impara l'IA / Machine LearningReti neurali, ML e LLM da zero Impara C e C++ Puntatori, memoria, STL e C++ moderno Impara C#Fondamenti, OOP, LINQ, async ed esercizi .NET Impara MatplotlibGrafici a linee, barre, dispersione e torta con visualizzatori Impara RustOwnership, trait, gestione degli errori e thread Impara GoSlice, interfacce, goroutine e canali Algoritmi Python Ricerca, ordinamento, ricorsione e visualizzazioni O(n) Algoritmi C e C++ Confronta le implementazioni in C e C++ Programmazione per bambini Impara a programmare giocando!
- QuizNuovo
- SfideNuovo
- Per docentiNuovo
- Aggiornamenti
- Offrimi un caffè
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.
Domanda di esempio
Domanda 1 di 10What 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()andfilter()return, and what their callbacks receive reduce()with and without an initial valuefind()vsfilter()vsforEach()- 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.