Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Uitdaging: Array-Elementen Wijzigen Met map() | Geavanceerde Arraymethoden en Transformaties
Javascript Datastructuren

bookUitdaging: Array-Elementen Wijzigen Met map()

Taak

Een array met getallen die temperaturen in Celsius voorstellen wordt gegeven. Gebruik de map()-methode om een nieuwe array te maken, waarbij elke temperatuur wordt omgezet naar Fahrenheit.

  1. Gebruik de map()-methode om een nieuwe array genaamd fahrenheitTemperatures te maken door elke temperatuur van Celsius naar Fahrenheit om te zetten.
    • De conversieformule is: F = (C * 1.8) + 32, waarbij F Fahrenheit is en C Celsius.
  2. Log de initiële array celsiusTemperatures naar de console.
  3. Log de aangepaste array fahrenheitTemperatures naar de console.
12345678910
// Initial array const celsiusTemperatures = [0, 25, 100, -5, 15]; const fahrenheitTemperatures = ___.___((celsius) => { return celsius * ___ + ___; }); // Log the initial and modified arrays console.log("Initial array:", celsiusTemperatures); console.log("Modified array:", fahrenheitTemperatures);
copy

Verwachte uitvoer:

Initial array: 0, 25, 100, -5, 15
Modified array: 32, 77, 212, 23, 59
  1. Voor het aanmaken van een nieuwe array met de map()-methode, map() aanroepen op de oorspronkelijke array en een callbackfunctie opgeven die de transformatie voor elk element definieert.
  2. Deze formule (F = (C * 1.8) + 32) gebruiken binnen de callbackfunctie.
12345678910
// Initial array const celsiusTemperatures = [0, 25, 100, -5, 15]; const fahrenheitTemperatures = celsiusTemperatures.map((celsius) => { return celsius * 1.8 + 32; }); // Log the initial and modified arrays console.log("Initial array:", celsiusTemperatures); console.log("Modified array:", fahrenheitTemperatures);
copy

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 5. Hoofdstuk 2

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Suggested prompts:

Can you explain how the map() method works in this example?

What would happen if the array contained non-numeric values?

Can you show how to convert the temperatures back from Fahrenheit to Celsius?

Awesome!

Completion rate improved to 2.27

bookUitdaging: Array-Elementen Wijzigen Met map()

Veeg om het menu te tonen

Taak

Een array met getallen die temperaturen in Celsius voorstellen wordt gegeven. Gebruik de map()-methode om een nieuwe array te maken, waarbij elke temperatuur wordt omgezet naar Fahrenheit.

  1. Gebruik de map()-methode om een nieuwe array genaamd fahrenheitTemperatures te maken door elke temperatuur van Celsius naar Fahrenheit om te zetten.
    • De conversieformule is: F = (C * 1.8) + 32, waarbij F Fahrenheit is en C Celsius.
  2. Log de initiële array celsiusTemperatures naar de console.
  3. Log de aangepaste array fahrenheitTemperatures naar de console.
12345678910
// Initial array const celsiusTemperatures = [0, 25, 100, -5, 15]; const fahrenheitTemperatures = ___.___((celsius) => { return celsius * ___ + ___; }); // Log the initial and modified arrays console.log("Initial array:", celsiusTemperatures); console.log("Modified array:", fahrenheitTemperatures);
copy

Verwachte uitvoer:

Initial array: 0, 25, 100, -5, 15
Modified array: 32, 77, 212, 23, 59
  1. Voor het aanmaken van een nieuwe array met de map()-methode, map() aanroepen op de oorspronkelijke array en een callbackfunctie opgeven die de transformatie voor elk element definieert.
  2. Deze formule (F = (C * 1.8) + 32) gebruiken binnen de callbackfunctie.
12345678910
// Initial array const celsiusTemperatures = [0, 25, 100, -5, 15]; const fahrenheitTemperatures = celsiusTemperatures.map((celsius) => { return celsius * 1.8 + 32; }); // Log the initial and modified arrays console.log("Initial array:", celsiusTemperatures); console.log("Modified array:", fahrenheitTemperatures);
copy

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 5. Hoofdstuk 2
some-alt