Created
August 22, 2020 10:33
-
-
Save iamsaief/b5d2b3944ee5e9ff54df564dd3cdf7ad to your computer and use it in GitHub Desktop.
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
/* Map */ | |
const numbers = [2, 3, 4, 5, 6, 8]; | |
const squaredNum = numbers.map((num) => num * num); | |
console.log(squaredNum); | |
// Output : [ 4, 9, 16, 25, 36, 64 ] | |
/* Filter */ | |
const shapes = ["π¨", "π©", "π΅", "π΄", "π¨", "π©", "π΅", "π΄"]; | |
const circle = shapes.filter((item) => item === "π΄"); | |
const square = shapes.filter((item) => item === "π©"); | |
console.log(circle); | |
console.log(square); | |
// Output : ["π΄", "π΄"] | |
// Output : ["π©", "π©"] | |
/* Find */ | |
const hearts = ["π", "π", "π§‘", "π", "π"]; | |
const greenH = hearts.find((item) => item === "π"); | |
console.log(greenH); | |
// Output : π |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment