Support us on our Patreon page: https://www.patreon.com/codebabes
Take the full course here: https://codebabes.com/courses/programming-virgin-javascript
Alright, are you ready for the “hard” stuff? We’ve talked about where you can stick your data, but what about storing actions, stuff that manipulates that data? We need functions.
We’ve already seen some functions in action, like prompt and alert. These functions are baked into the language. You can just use them. When you pass a value into them, that value is called an argument.
When you are using alert you are calling the alert function. You’re saying hey, function do some shit.
But you can also write your own functions which is where things start to get interesting. If you weren’t interested already. (Push up)
Let’s create a simple function named cockBlock. Write the keyword “function”, then the name of the function, cockBlock, then parentheses, which remain empty for a simple function like this, then a set of braces to define the block that the function will execute when called. Inside there we’ll put the alert, “keep it in your pants.” It’s good to have a function name relate to what it’s actually doing.
Now let’s go back to our html page and refresh. You’ll see that nothing happens. This is because you have to call the function before it will run.
To call a function, just write out the function name, the two parentheses and a semicolon. When you refresh the page you’ll see an alert pop up.
Let’s get a little more advanced. Functions can also contain variables. So let’s create a function called addNumbers. In the function block we’ll add the variables A equals 2 and B equals 10. Then sum is equal to A plus B. We use the return keyword to get the function to output a value when called. We’ll do return sum. Now if we log the function call, we’ll see 12.
But that’s pretty rigid, the only thing we can get out is 12. That’s where arguments come in. Instead of putting the variables in the function block, we’ll put them in the parentheses after the function name, like this: (gesture)
Now the A and B values are going to be passed in as arguments when the function is called. Call the function addNumbers and then in the parentheses of the function call we put the arguments, let’s do 7 and 11. The great thing about functions is they can be used over an over. They’re a great way to make your code more modular.
So that’s it for the intro to programming lesson thanks for trying to pay attention.
https://codebabes.com/courses/programming-virgin-javascript
Original source
22 responses to “Programming with Functions in JavaScript – Programming Virgin”
That moment you feel Youtube was cockBlocking(){String hot=" holding back on the search results."}
when will be next episode?
I just want to know how to code lol
pretty smart way to get views. Props
damn it wheres the other chic.
Anyone else notice she has a wookie amount of hair on her back?
I think I may have broken the youtube player rewinding that intro… and my d*ck too
your tutorial is very good. Please upload next video in the series, bcoz i am so excited..
hot tho i disagree with the chosen style of indentation.
Um, why isn't this bitch in the kitchen?
it sucks sometimes
foul
Good explanation here,
Minus for boobs 😀
Shit should be separated, lol
I lov to read listen and study 24 hours. If a super hot sexy teacher expose herself and teachus.
Maaann…..shit
wtf is this?? xDD
pls make videos for C programming
What's here Instagram?
that skin, i cant study……………why you do this
I'm learning, I'm learning!
thank you so much
learning while fapping has never been this easy or fun