JavaScript Tutorial For Beginners #20 - Functions

preview_player
Показать описание
Hey class, so in this JavaScript tutorial I want to introduce you to the world of functions. Yep, I think you're ready for them :). Functions allow you to chunk parts of code together into logical sections, and call that code at any time. For example, you may have a function to cycle through all of your images on a web page, and implement a zoom functionality on the. You'd probably call this function something like imageZoom.

So, functions are a really cool and integral part of JavaScript, and something you should try and get into the habit of using early on in your JavaScript development, so that your code is always readable and tidy for yourself and other developers.

At first, functions in JavaScript can be a tricky concept, so by all means fire away with any questions you have down below :).

========== JavaScript for Beginners Playlist ==========

========== CSS for Beginners Playlist ==========

========== HTML for Beginners Playlist ==========

========== The Net Ninja ============

========== Social Links ==========

Рекомендации по теме
Комментарии
Автор

I could say this on every video... I wish I'd found these sooner instead wasted about a month doing 10 different "beginners" course done by "techies" that don't understand the word "beginner" - those were so much gobblygook that I had to go to the hospital because my head exploded. Anyway, I was just thinking that 4 of those guys down rated the video because they were mad that you keep pulling aside the curtain aside to reveal the great and powerful Oz.

vincecaruso
Автор

Bro at 33 I start my career in web dev .with ur lessons it seems easy .thanks for these pricey tutorial s
For free .love the way u explain.😍😍😍😍😍😍😍😍love from INDIA

kashi
Автор

You explain things at an awesome pace for me man thank you!!! Love your videos!!

aaronharris
Автор

You're very good at explaining. No BS, no fluff.
Thank you.

marakeshg
Автор

Best js tutorial out in the youtube..
when do you use return value in function?..got a little confused on how to use "return value".

Sir_Curvine
Автор

I fcking love the intro :) ... and of course the way you explain stuff.

matijasekelj
Автор

Superb explanation. Much better than Udemy. Thanks shinobi

rarriesgado
Автор

This example will take any number of numbers:

function getAvg (...args) {
sum = 0;
for (i=0; i < args.length; i++) {

sum += args[i];

}
return sum/args.length;
}

KubaSobecki
Автор

Thanks for the tutorial, this is the best explanation that i found so far. I will definitely recommend you channel

css-chef
Автор

function getAverage () {
var sum = 0;
for (i=0; i <arguments.length; i++) {
sum += arguments[i];
}
var average = sum/arguments.length;
console.log(average);
return average;
}

var myResult = getAverage(7, 12, 33, 45, 1178, 12, 45, 745, 52, 742, 81, 5, 4, 0);
console.log("The average is "+ myResult)

omikronweapon
Автор

Best of best in YouTube channel ..I recommended your channel.so much. ...

oghenefokethompson
Автор

Bro, Please make the font size a bit bigger on Bracket!

xaif
Автор

why does brackets keep giving me error in the words document and console? it says they are not defined

BrunoMorais
Автор

var a = parseInt(prompt("1 Number: "));
var b = parseInt(prompt("2 Number: "));
document.write("The average is: " + (a+b)/2);
This works also, but I was struggling to write it as a function. Do you have any advise?
God bless you

niecierpliwy
Автор

Hi there, thank you for the video upload. May I ask what does "return" do? When is it necessary to include "return"?

Thank you!

darentan
Автор

8:31 made me wonder - do functions have a ".length"-method? I would have tested it, but am not at my API atm and I am almost certain to forget the question until then. 😀Also - sorry for the necro

Eckister
Автор

// Enjoyed this one [Code] function getAverage(a, b, c){

var average = (a + b + c) / 2;
console.log(average);
return average;
}
var finalResult = getAverage(10, 10, 10);
document.write("your final result is .... " + finalResult);

aqeemjones
Автор

i assume 'get average' here is an arbitrary name and not a pre-defined function/pre-programmed function. you could have named it anything? so because of this you created your own function which is (a+b)/2. am i correct in my thinking? thank you, p.s. keep up the good work

rm
Автор

this went from lv 19 to lv 30 real quick

codingacc
Автор

At around three minutes in, could you have the "average" variable as a local variable? Then in the code block, you can just say "average = (a + b) / 2"?

ProPavGamingIsBae