Skip to content

Instantly share code, notes, and snippets.

@hebertcisco
Created May 23, 2020 05:30
Show Gist options
  • Save hebertcisco/391d284bbed28f1c1b5118bc9c95df96 to your computer and use it in GitHub Desktop.
Save hebertcisco/391d284bbed28f1c1b5118bc9c95df96 to your computer and use it in GitHub Desktop.
The map () method invokes the callback function passed by argument for each element of the Array and returns a new Array as a result.
const temperatureCelsius = [0, 22, 31, 40, 45, 12, 3];
const toFahrenheit = (value) => (value * 9) / 5 + 32;
const temperatureFahrneheit = temperatureCelsius.map(toFahrenheit);
console.log(temperatureCelsius);
console.log(temperatureFahrneheit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment