From c99b873ce295245d59d53999478f97050bee544e Mon Sep 17 00:00:00 2001 From: Waqar Ansari <40629788+mdwaqaransari@users.noreply.github.com> Date: Sat, 17 Oct 2020 16:53:14 +0530 Subject: [PATCH] commit map_function --- src/map_function.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/map_function.js diff --git a/src/map_function.js b/src/map_function.js new file mode 100644 index 0000000..38686a2 --- /dev/null +++ b/src/map_function.js @@ -0,0 +1,12 @@ +// By using map function you can iterate to an array and apply some filter to it. +// Map function receives a callback function. +// Will return only if the number is even. + +var arr = [1,5,4,8,11]; + +var printed =arr.map(item=>{ + if(item%2==0) {return item}; + }); + + console.log(printed); +