This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sumSales = (accumalator, element) => accumalator + element.sales | |
const totalSales = users.reduce(sumSales, 0) | |
console.log(totalSales) // 49991 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapAge(array) { | |
const mapped = [] | |
for (let i = 0; i < array.length; i++) { | |
mapped.push(array[i].age) | |
} | |
return mapped | |
} | |
const mappedAges = mapAge(users) // [26, 55, 29, 49, 19, 25, 26, 32] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mapAges = users.map(element => element.age) // [26, 55, 29, 49, 19, 25, 26, 32] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const map = (array, transform) => { | |
mapped = [] | |
for(let i = 0; i < array.length; i++) | |
mapped.push(transform(array[i])) | |
return mapped | |
} | |
const mapAges = map(users, element => element.age) // [26, 55, 29, 49, 19, 25, 26, 32] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sales = [ | |
{ name: 'João', amount: 11792.23, currency: 'BRL', country: 'Brazil', language: 'pt-BR' }, | |
{ name: 'Manoel', amount: 3899.05, currency: 'EUR', country: 'Portugal', language: 'pt-PT' }, | |
{ name: 'José', amount: 259, currency: "USD", country: 'United States', language: 'en-US' } | |
] | |
const formatCurrency = ({ amount, language, currency }) => { | |
return { | |
amountFormatted: amount.toLocaleString(language, { style: 'currency', currency: currency }) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ amountFormatted: "R$11.792,23" }, | |
{ amountFormatted: "3 899,05 €" }, | |
{ amountFormatted: "$259.00"} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
return ( | |
<> | |
<h1>Dipeex</h1> | |
<a href=”http://medium.com/dipeex">Medium</a> | |
</> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
return [ | |
<li key=”A”>First item</li>, | |
<li key=”B”>Second item</li>, | |
<li key=”C”>Third item</li> | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Criação do componente Wrapper | |
const Wrapper = ({ children }) => children | |
// utilizando o componente Wrapper | |
render() { | |
return ( | |
<Wrapper> | |
<h1>Dipeex</h1> | |
<a href=”http://medium.com/dipeex">Medium</a> | |
<Wrapper/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Fragment } from ‘react’ | |
render() { | |
return ( | |
<Fragment> | |
<div className=”title”> | |
<h1>Dipeex</h1> | |
<a href=”http://medium.com/dipeex">Medium</a> | |
</div> | |
<ChildA /> |