| *** shmohamud has quit (Ping timeout: 480 seconds) | 00:34 | |
| *** shmohamud has quit (Ping timeout: 480 seconds) | 01:28 | |
| *** shmohamud has quit (Ping timeout: 480 seconds) | 04:20 | |
| *** scooper has quit (Ping timeout: 480 seconds) | 06:42 | |
| *** sysadmin has quit (Ping timeout: 480 seconds) | 07:02 | |
| *** sysadmin has quit (None) | 07:05 | |
| scooper | ACTION signing up still tomorrow same time | 11:21 | 
|---|---|---|
| *** scooper has quit (Quit: Leaving) | 11:22 | |
| *** scooper has quit (Quit: Leaving) | 12:30 | |
| *** shmohamud has quit (Remote host closed the connection) | 19:45 | |
| *** shmohamud has quit (Remote host closed the connection) | 19:54 | |
| scooper | Hello Shmohamu | 19:55 | 
| *** shmohamu_ has quit (Remote host closed the connection) | 19:57 | |
| shmohamud | hi scooper | 20:05 | 
| scooper | hi shmohamud | 20:05 | 
| scooper | I m here now | 20:06 | 
| shmohamud | Awesome | 20:07 | 
| shmohamud | So, did I give homework last time? | 20:07 | 
| scooper | hmmm no | 20:07 | 
| shmohamud | Ok, do you have any questions for me before we review last time? | 20:08 | 
| scooper | yes | 20:08 | 
| shmohamud | lets hear it | 20:08 | 
| scooper | So we you mentioned the different type of function in JS | 20:09 | 
| scooper | So you mentioned the different type of function in JS | 20:09 | 
| shmohamud | yes | 20:09 | 
| scooper | Which one is mostly use and mostly consider?? | 20:10 | 
| scooper | (function myFirstFunction(){ } myFirstFunction(); | 20:11 | 
| scooper | function myFirstFunction(){ } myFirstFunction(); | 20:12 | 
| scooper | (function myFirstFunction ()=>{ } myFirstFunction(); arrow function | 20:12 | 
| scooper | the above three function I mentioned which one is mostly consider??? | 20:13 | 
| shmohamud | I don't know which one is more widely used, but I think today more people use arrow functions as opposed to function declarations | 20:13 | 
| scooper | OK | 20:14 | 
| shmohamud | what I do know is that it's important for you to know arrow functions and function declarations because they're both widely used | 20:14 | 
| scooper | ok | 20:14 | 
| shmohamud | Different scenarios require different functions. If you need the function to be "hoisted" then use a function declaration. If you're defining a callback, arrow functions are often used because the syntax is shorter | 20:15 | 
| shmohamud | can you write me a function called addNumbers that has two parameters, a and b, and it console.log(a + b) | 20:17 | 
| shmohamud | ? | 20:17 | 
| scooper | ok | 20:18 | 
| shmohamud | you can do function declaration or arrow function, whichever you prefer | 20:18 | 
| scooper | const function addNumber(a,b){ | 20:25 | 
| scooper | console(a+b) | 20:25 | 
| scooper | } | 20:25 | 
| scooper | addNumber(4,5): | 20:25 | 
| scooper | please hold on a came with an error | 20:25 | 
| shmohamud | when you declare a function do you need the const keyword? | 20:26 | 
| scooper | no | 20:26 | 
| scooper | I think I should have use let or var | 20:27 | 
| scooper | because const don't allow redeclaration right??? | 20:27 | 
| shmohamud | You can use any of them but only if you're writing a function express. Like const addNumbers = function(a,b){ } | 20:27 | 
| shmohamud | var addNumbers = function(a,b){} | 20:27 | 
| shmohamud | let addNumbers = function(a,b){} | 20:28 | 
| shmohamud | but that's for function expressions. When you declare a function, there's no need to add const/let/var at all. | 20:28 | 
| shmohamud | Just keep it as function addNumbers(a, b){ } | 20:28 | 
| scooper | ok | 20:29 | 
| shmohamud | there's one more error. Do you see it? | 20:29 | 
| scooper | In my function?? | 20:30 | 
| scooper | definition | 20:30 | 
| shmohamud | in the function body | 20:31 | 
| shmohamud | what happens when you try to run it? | 20:31 | 
| scooper | it cause a typo error | 20:32 | 
| shmohamud | paste the code you're running here | 20:32 | 
| scooper | I got it | 20:33 | 
| scooper | const addNumber = function(a,b){ | 20:33 | 
| scooper | console.log(a+b) | 20:33 | 
| scooper | 20:33 | |
| scooper | } | 20:33 | 
| scooper | addNumber(4,5) | 20:33 | 
| shmohamud | nice, what was the error? | 20:33 | 
| scooper | the error can from the way I first define the function | 20:34 | 
| shmohamud | what in the function body was incorrect? | 20:34 | 
| scooper | instead of console.log I had console | 20:35 | 
| shmohamud | exactly | 20:35 | 
| shmohamud | that's what I wanted to hear! How did you catch the error? | 20:35 | 
| scooper | yes | 20:35 | 
| scooper | Sorry you asking a question??? | 20:37 | 
| shmohamud | Lol yes I'm asking a question --- how did you know to change console to console.log? | 20:37 | 
| shmohamud | Did the error message help you at all? I'm asking because it's a key skill you must learn is to read error messages and learn what they mean | 20:38 | 
| scooper | because I went through my code line by lines | 20:38 | 
| scooper | yes the error message help me too | 20:38 | 
| shmohamud | Good | 20:38 | 
| scooper | because it said type error | 20:38 | 
| scooper | because it say typo error | 20:39 | 
| shmohamud | Now can you rewrite the same function, except this time don't make it a function expression, keep it as a function declaration. Can you do that? | 20:39 | 
| scooper | ok | 20:39 | 
| scooper | let me try | 20:40 | 
| scooper | const addNumber = function(){ | 20:41 | 
| scooper | console.log() | 20:41 | 
| scooper | } | 20:41 | 
| scooper | addNumber(); | 20:41 | 
| shmohamud | is that a function declaration or a function expression? | 20:42 | 
| scooper | hmmm it's a function declaration because the function don't have | 20:44 | 
| shmohamud | No, it's a function expression because you're setting a variable equal to the function declaration. | 20:44 | 
| scooper | parameter and an argument though it have print statement and a function call | 20:44 | 
| shmohamud | Anytime you see an equal sign and a function it's a function expression | 20:44 | 
| shmohamud | function expressions and function declarations can both have parameters in the definition | 20:45 | 
| scooper | what if I do this | 20:45 | 
| scooper | const addNumber function(){ console.log}addNumber(): | 20:46 | 
| shmohamud | close, but do you need to put the const there? | 20:46 | 
| shmohamud | also, why did you remove the parameters and arguments? | 20:47 | 
| scooper | because I m declaring a function that why | 20:47 | 
| scooper | in JS to declare something you need to use the follow reserved key word | 20:47 | 
| scooper | let, var or const | 20:47 | 
| shmohamud | You don't need to use const , var, let when you're declaring a function | 20:47 | 
| shmohamud | try it and see for yourself :) | 20:48 | 
| scooper | ok | 20:48 | 
| scooper | ncaught SyntaxError: Unexpected token 'function' | 20:49 | 
| scooper | I received error | 20:49 | 
| scooper | addNumber function(){ | 20:49 | 
| scooper | console.log() | 20:49 | 
| scooper | } | 20:49 | 
| scooper | addNumber(); | 20:49 | 
| shmohamud | that's because you must put function before the name of the function. So function addNumber | 20:49 | 
| scooper | hmmm it work | 20:51 | 
| scooper | function addNumber(){ | 20:51 | 
| scooper | console.log() | 20:51 | 
| scooper | } | 20:51 | 
| scooper | addNumber(); | 20:51 | 
| shmohamud | can you add back the parameters and make sure to call it with arguments? | 20:51 | 
| shmohamud | See if that works ... | 20:52 | 
| scooper | it seems to be a bit tracky here | 20:52 | 
| scooper | let me give it a try | 20:52 | 
| scooper | function addNumber(a,b){ | 20:53 | 
| scooper | console.log(a+b) | 20:53 | 
| scooper | } | 20:53 | 
| scooper | addNumber(4,10); | 20:53 | 
| shmohamud | did that work? | 20:53 | 
| scooper | yes | 20:54 | 
| shmohamud | did you need to add let, var, const to declare the function? | 20:54 | 
| scooper | I got an output of 14 in the | 20:54 | 
| scooper | from what I did, I didn't think so it really necessary | 20:55 | 
| shmohamud | Yes, you don't need let, var, const to have a function declaration | 20:56 | 
| scooper | Now I know, thanks Sahnun | 20:56 | 
| shmohamud | Of course, way to stick with the question. This is tricky stuff. | 20:57 | 
| shmohamud | So, do you have any questions for me? | 20:57 | 
| scooper | yes | 20:57 | 
| shmohamud | lets hear it | 20:57 | 
| scooper | let me get something clear here, in python we use indentation for a particular block so, can I consider curly bracket to be js own of indentation?? | 20:58 | 
| shmohamud | Yes, the syntax to declare a function block is that it must go in curly brackets (unless it's a special kind of arrow function, which we will discuss later) | 20:59 | 
| shmohamud | You can think about it similar to the way you think about Python indentation. It's how we define the function body / block | 21:00 | 
| *** scooper has quit (Ping timeout: 480 seconds) | 21:11 | |
| *** shmohamud has quit (Remote host closed the connection) | 21:13 | |
| *** shmohamud has quit (Remote host closed the connection) | 21:17 | |
| *** shmohamud has quit (Remote host closed the connection) | 21:21 | |
| *** shmohamud has quit (Ping timeout: 480 seconds) | 21:32 | |
Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!