IRC log of #novawebdev for Thursday, 2023-10-19

*** shmohamud has quit (Ping timeout: 480 seconds)01:06
*** scooper has quit (None)04:48
*** shmohamud has quit (Ping timeout: 480 seconds)09:08
fkoikoiGood Morning Jeff11:00
*** fkoikoi has quit (Remote host closed the connection)11:00
*** fkoikoi_ has quit (Remote host closed the connection)11:02
*** jelkner has quit (Quit: Leaving)11:06
*** dcammue_ has quit (None)11:07
*** fkoikoi_ has quit (Ping timeout: 480 seconds)11:19
*** fkoikoi_ has quit (Quit: Leaving)12:50
scooperGood afternoon Sahnun20:25
scooperhow was work today???20:25
shmohamudGood evening Spencer20:26
shmohamudit was excellent, thanks for asking20:26
shmohamudDid you complete the homework I assigned?20:26
scooperUnfortunately I could locate the assignment where I save, can you please paste it again.....20:27
shmohamudIt's in the IRC logs20:28
shmohamudWrite two arrow functions. The first one should not include a return statement and the second one should have multiple lines and include a return statement.20:29
shmohamudCan you do it now?20:29
scooperlet me check20:29
scooperok thanks, let me attempt doing it20:29
scooperconst mutiplication = (a,b)=>{20:33
scooper    console.log(a+b)20:33
scooper}20:33
scoopermutiplication(4,5);20:33
*** shmohamud has quit (Remote host closed the connection)20:35
scooperconst mutiplication = (a,b)=>{20:36
scooper    c = a+b;20:36
scooper    d = a+b;20:36
scooper    return c20:36
scooper}20:36
scoopermutiplication(4,5);20:36
scoopersorry error20:36
shmohamudso for the multiplication function, are you multiplying or adding inside of it?20:36
scooperconst mutiplication = (a,b)=>{20:37
scooper    c = a+b;20:37
scooper    return c20:37
scooper}20:37
scoopermutiplication(4,5);20:37
scooperoh20:37
scooperit was a mistake20:37
scooperconst mutiplication = (a,b)=>{20:38
scooper    c = a*b;20:38
scooper    return c20:38
scooper}20:38
scoopermutiplication(4,5);20:38
shmohamudperfect, now how about an arrow function without curly braces and no return statement?20:38
scooperok20:39
scooperlet me attempt it20:39
shmohamudactually, can you start by setting some variables equal to both of the multiplication functions?20:39
scooperS20:39
shmohamudLet's see what happens when you have no return statement vs. having a return statement20:39
scooperdo you I should use comparison operator in my function???20:40
shmohamudso for one of them, remove "return c" 20:40
scooperDO you mean I should use comparison operator in my function20:40
shmohamudNo need to use comparison operator20:40
shmohamudI mean set testVariable = multiplication(3,4)20:40
scooperooh got you now20:41
shmohamudand then testVariableTwo = otherMultiplication(3,4)20:41
*** shmohamud has quit (Remote host closed the connection)20:45
scooperconst mutiplication = (a,b)=>20:47
scooper    c = a+b;20:47
scoopertestVariable= mutiplication(4,5);20:47
shmohamudsorry my laptop fell asleep. Did you paste your results yet?20:47
scooperyes20:47
scooperconst mutiplication = (a,b)=>20:47
scooper    c = a+b;20:47
scoopertestVariable= mutiplication(4,5);20:47
scooperplease hold on20:48
shmohamudok20:48
scooperit make a mistake in the naming convention20:48
shmohamudok20:48
scooperconst mutiplication = (a,b)=>20:48
scooper    c = a*b;20:48
scoopertestVariable= mutiplication(4,5);20:48
scooperhere is it20:48
shmohamudwhat do you expect testVariable to equal?20:49
scooper2020:49
shmohamudrun it and let me know what you get20:50
scooperIt got 2020:50
shmohamudone momen20:50
shmohamudone moment20:50
scooperconst mutiplication = (a,b)=>20:50
scooper    c = a*b;20:50
scoopertestVariable= mutiplication(4,5);20:50
scooper    20:50
scooper2020:50
scooperare you still there??20:53
shmohamudyes20:53
shmohamudthat was a good job. I was surprised myself because I thought it would return undefined but clearly it's 2020:53
shmohamudyou're correct20:53
shmohamudit makes sense because it has no curly braces and returns whatever the single line is, in this case that would be "c" which equals 4*520:54
scooperCan I say something20:54
shmohamudof course20:54
scooperFirst I ran the code without the curly bracket and kept the return statement in the arrow function it give me an output of undefined20:55
scooperso I remove the return statement and ran the program it, it give me 2020:55
scooper*again20:56
shmohamudGood job testing that out, I'm not sure why having a return statement would make it undefined without curly brackets. When there are no brackets on an arrow function, it returns whatever the line of code is20:57
shmohamudI thought return statements are not allowed for single line arrow functions without curly brackets20:58
shmohamudThis is what i get when i run that20:58
shmohamudSyntaxError: Unexpected token 'return'20:58
shmohamudI don't think return statements are allowed if it's an arrow function without curly brackts20:59
scooperwhich code??? give you that error msg20:59
shmohamudconst multiplyyy = (a,b) => return c=a*b20:59
scooperShanun21:02
shmohamudyes21:02
scooperif you do it like this, it will work21:02
scooperconst mutiply = (a,b) => c = a*b21:02
scoopertestAndSee = mutiply(4,5)21:02
shmohamudyes, I know that works, but you said you got undefined with the return statement...?21:03
shmohamudI was wondering how that's possible. Maybe you got a syntax error like me?21:03
scooperyes21:03
scooperlet me run that previous program and post the error mgs21:04
shmohamudI'll be right back21:04
scooperok21:04
shmohamudin the meantime I want you to write an arrow function with curly brackets with a return statement, and then without a return statement. Compare the values of them.21:04
shmohamudok I'm back21:07
*** shmohamud has quit (Remote host closed the connection)21:11
scooperconst learning = (message) => {21:14
scooper    return message21:14
scooper    21:14
scooper}21:14
scooper    testing = learning("Let learn to code together")21:14
scooper'Let learn to code together'21:14
scooperconst learning = (message) => {21:15
scooper    message21:15
scooper    21:15
scooper}21:15
scooper    testing = learning("Let learn to code together")21:15
scooperundefined21:15
shmohamudPerfect21:16
shmohamuddo you see the difference when we use the return statement vs when we don't?21:16
scooperyes21:16
shmohamudin javascript function declarations AND arrow functions with curly brackets, we must have the return statement in there or else it will always return undefined21:17
shmohamudOk, do you have any questions for me before we call it a day here?21:18
scooperI will send my question later not now I m a bit exhausted now21:19
scooperbefore you leave21:19
shmohamudSounds good.21:19
shmohamudYes?21:19
scooperWhen are we moving on to the next topic???21:20
shmohamudonce we're solid on function declarations and arrow functions. I think next session we can continue to logical operators and conditionals (==, ===, >=, <=, ||, &&, if, else, else if, switch)21:21
scooperperfect switch might be the only conditional statement see complicated for me21:22
shmohamudok, but the syntax for JS is different from python, it might take some getting used to21:23
scooperI been practicing Sahnun21:23
scooperespecially understanding the differences between double equal and triple equal21:23
shmohamudI can tell, keep up the good work. We have a lot of work left to get you to professional level JS master21:24
scooperdouble pipe is the same as or operator in python21:24
shmohamudgood21:24
scooper&& is the same a and operator in python21:24
scooperShanun is ternary operator often use in js??21:26
shmohamudawesome, it should come easy next time21:26
shmohamudIt's used enough that it's important to know21:26
shmohamudif (condition)? A : B21:26
scooperIt's a bit confusing, when I came across it21:27
scooperBut will figure how to get around it in the shortest possible time...21:27
shmohamudDon't worry, you will get it soon. It's not too different from other conditional logic.21:28
shmohamudif(condition) ? [do this] : [do this]21:28
shmohamudif it's true, do the first one, if it's false, do the second one21:28
scooperok21:29
scooperthanks Shmohamud can I get a nap now?? it 9:30pm on my end???21:30
shmohamudYou're welcome. Keep up the good work. We'll meet again tomorrow or Monday.21:30
scooperOK thanks21:30
scooperACTION signing out for now21:30
*** scooper has quit (Quit: Leaving)21:30
*** shmohamud has quit (Remote host closed the connection)21:31
*** shmohamud has quit (Remote host closed the connection)23:36

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!