Tech Junkie Blog - Real World Tutorials, Happy Coding!: JavaScript Array Methods: map() Method

Monday, November 15, 2021

JavaScript Array Methods: map() Method

The map() method is similar forEach() method which means that it performs a function, however it returns a new array with the returned values.  In this example we are going to perform the $1 discount of the oil prices using the map() method instead of the forEach() the difference here is that the map() method returns a new array instead of the original array, but the result will be the same.


    <script>
        var oilPrices = [70.15, 69.50, 71.23, 74.32, 76.99];

        var discounted = oilPrices.map(function (value) { return value -1; });

        console.log(discounted);
    </script>




The code above calls the map() method on the oil prices and returns a discounted value of $1 for each array element















2 comments:

  1. Thanks for your attention on the matter.

    ReplyDelete





  2. error404-store




    - -- Spamming tools --




    1-- cpanel https ssl secure
    2-- shell ssl secure
    3-- web-mail
    4-- smtp
    5-- rdp with send bluster
    6-- scam pages
    7-- ceo or cfo leads




    -- Spy virus slinet Exploits --




    1-- privet rat
    2-- crypter exploits
    3-- privet rdp hosting
    4-- os andriod spy virus
    5-- iso iPhone spy virus
    6-- Nokia spy virus




    - -- scanners brute-force ---




    1-- linux roots
    2-- cpanel scanner
    3-- cpanel bruter
    4-- shell scanner
    5-- smtp scanner
    6-- smtp bruter
    7-- zimbra scanners


    - -------------------


    cpanel,shell,smtp,scampages,sender,ceo or cfo leads,rdp,spyvirus,crypter,exploits,scanners


    Telegram:- @Donsmith000


    icq :- @Donsmith000


    https://error404-store.blogspot.com



    ReplyDelete

Search This Blog