pull/334/merge
krishna 7 months ago committed by GitHub
commit 2dc96cd930
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3432,9 +3432,9 @@ For example if we like to change each country to uppercase and store it back to
```js ```js
const countries = ['Finland', 'Estonia', 'Sweden', 'Norway'] const countries = ['Finland', 'Estonia', 'Sweden', 'Norway']
const newCountries = [] const newCountries = []
countries.forEach((country) => newCountries.push(country)) countries.forEach((country) => newCountries.push(country.toUpperCase))
console.log(newCountries) // ["Finland", "Estonia", "Sweden", "Norway"] console.log(newCountries) // ["FINLAND", "ESTONIA", "SWEDEN", "NORWAY"]
``` ```
Let us see more examples. For instance if we want to sum an array of numbers we can use forEach or reduce. Let us see how we use forEach to sum all numbers in an array. Let us see more examples. For instance if we want to sum an array of numbers we can use forEach or reduce. Let us see how we use forEach to sum all numbers in an array.

Loading…
Cancel
Save