Use These Instead Of A For Loop Javascript

[Solved] Use These Instead Of A For Loop Javascript | Solidity - Code Explorer | yomemimo.com
Question : use these instead of a for loop javascript

Answered by : brainy-butterfly

const array = [1, 2, 3];array.forEach(function(elem, index, array) { array[index] = elem * 2;});console.log(array); // [2,4,6]

Source : https://medium.com/better-programming/never-write-another-for-loop-in-javascript-9db11afa6445 | Last Update : Sat, 01 Feb 20

Question : use these instead of a for loop javascript

Answered by : brainy-butterfly

const array = [1,2,3,4,5];const evenNumbers = array.filter(function(elem) { // expressions that return 'true' are retained return elem % 2 == 0;});

Source : https://medium.com/better-programming/never-write-another-for-loop-in-javascript-9db11afa6445 | Last Update : Sat, 01 Feb 20

Answers related to use these instead of a for loop javascript

Code Explorer Popular Question For Solidity