Skip to content

Instantly share code, notes, and snippets.

@Shariar-Hasan
Created February 2, 2021 14:41
Show Gist options
  • Save Shariar-Hasan/a030e1a219c7ccbb642ffdbb0ac60ee3 to your computer and use it in GitHub Desktop.
Save Shariar-Hasan/a030e1a219c7ccbb642ffdbb0ac60ee3 to your computer and use it in GitHub Desktop.
use of map,filter,find methods in array
let numbers = [1,2,3,4,5,6,7,8,9,10];
let result1 = numbers.map( (x) => x*10 );
console.log(result1);
let result2 = numbers.filter( (x) => x%2 ); //returns all values that meet the condition
console.log(result2);
let result3 = numbers.find( (x) => x%2 && x>4); //returns only one value that meet the condition
console.log(result3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment