About Default Values
Them just for one more example let's use another built-in function called a For Each loop. And what we can do is we can take in numbers here and we can just kind of maybe double each number and create a new array based on that. So that would look something like this. We can do Konst doubled numbers and this one let's make it a function so we'll take in some kind of numbers. I'm going to call it and we will do it six styles right off the bat. So you know what here I'm going to make a. Let's see an array. Costs number teener just going to be an empty array at first then we'll take whatever we are passed in the dot for each. And what this does it's going to run an online marketing company some whatever logic we tell it to run on each item in the array. In this case, is an array of numbers for each. Normally takes a function like this. 

We know that we can rewrite this through using ESX code. So in brackets, because that's just my personal preference we go through each item and this is just really a placeholder name. Right, so this can be X or numbers or whatever you need it to be. But basically, we're going to do one of these. And what constant doubled equals and times and then we'll push the number into number container. So number container push. So what this does is going to loop through top digital marketing companies in Pune create a new const for everyone so don't have to about cons being renamed or reassigned that's not what's happening it's just creating a new constant in memory for each of these. And then we can return after this loop completely. 

Types of Default Values
So for this block of code is done we can return the number container which works as top digital marketing companies in Pune at that point should have all of our numbers doubled inside of it. So let's check it out. We all console log the result of this but we do double the numbers. And it's a function which takes in an argument which will be numbers or numbers array. Let's check it out. Fingers crossed we'll run it. Hey, there we go. Looks like it worked just as expected. All right so not a huge no improvement in terms of minimizing our code but were able to get rid of the function keyword and kind of simplify it a little bit. And you know maybe we should call this number doubler instead of a number. 

DOBLER number Templer. So this takes in top digital marketing companies in Pune and to show off how it can be reusable. We know of course we can't just declare another constant const more Nomes equals five . And if we want to use our function for this array instead. Well, it's a reasonable function. So we just give it more Gnome's instead. It's clear to run again. There you go. And if you want to check the status of our bank account we can also cancel logs that constant out of bank account after the first purchase balance has gone down. Can Spend Money is true. Let's do it again here. And let's spend a lot more the first time let's be clear we run again. Balance has been brought down to zero. 

Can't spend money is false. And the second time we go through the balance is already zero. What about if we do case so we can purchase both times because we had one left in our balance and our balance is zero. On the other hand, if we don't want to use this default we don't have to. Right. So if we eliminate some of this code here get rid of the bank account cancel logs but top digital marketing companies in Pune purchased an item using a different bank account. Right. And it's expecting an object in here with the values of can't spend money and balance. So if we give it directly an object like so and we try to match it so it can spend money. True. Balance let's see we'll make the balance of this bank count or rather. So this one we should be able to purchase as well and we are just reusing the function year run. Both of these can be made in this case. We are not even using the default value. In other words, if we try to buy something worth we'll be able to purchase it right. 

But if we can't spend money is already on false. Well no we can't. All right. So a bit of a complex example but gives us a good chance to kind of practice an if statement, as well as an NSA and you, can see where you might use a nested IF statement. So, in any case, we are now able to pass in defaults directly like so instead of doing the check that we saw earlier. Initially, you can spend money like it's always true therefore it just goes ahead. Does the purchase then we say if the top digital marketing companies in Pune account balance goes less than or equal to zero we switched the flag can spend money to false. So we can purchase one item but we can't purchase another. What if we purchase one item that's and then we try to do another purchase cool. So it's definitely working.
Learn Default values in Javascript by top digital marketing companies in Pune