IRC log of #novawebdev for Friday, 2023-10-20

*** shmohamud has quit (Ping timeout: 480 seconds)00:06
*** shmohamud has quit (Remote host closed the connection)01:21
*** shmohamud has quit (Remote host closed the connection)02:32
*** scooper has quit (Ping timeout: 480 seconds)07:51
*** sysadmin_ has quit (Ping timeout: 480 seconds)07:51
ubuntouristClient: HexChat 2.16.0 • OS: Pop "jammy" 22.04 • CPU: Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz (800MHz) • Memory: Physical: 61.2 GiB Total (53.6 GiB Free) Swap: 19.5 GiB Total (19.5 GiB Free) • Storage: 1.6 TB / 5.8 TB (4.2 TB Free) • VGA: NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile / Max-Q] @ Intel Corporation 10th Gen Core Processor Host Bridge/DRA13:13
ubuntouristM Registers • Uptime: 1h 21m 44s13:13
ubuntouristExperimenting with HexChat...13:37
*** ubuntourist has quit (Quit: Leaving)13:41
scooperGood afternoon Sahnun20:31
shmohamudGood evening Spencer20:32
shmohamudReady for a quick review before we move to some JS logical operators and conditional statements?20:32
scooperyes20:33
shmohamudWrite me an arrow function that subtracts two numbers (a, b) and *returns* the result. 20:34
shmohamudHint: there is more than one way to do this.20:35
scooperconst subtraction = (a,b) =>{20:37
scooper    return c = a-b;20:37
scooper}20:37
scoopersubtraction(10,2);20:37
shmohamudok, when you set that equal to testVariable = subtraction(10, 2) what does testVariable equal?20:38
scooper820:39
scooperconst subtraction = (a,b) =>{20:39
shmohamudOk, perfect. 20:39
scooper    return c = a-b;20:39
scooper}20:39
scoopertestVariable = subtraction(10,2)20:39
scooper820:39
shmohamudyour function names are getting better each time. Good job using the return statement, too.20:40
shmohamudOk, let's have some fun with logical operators.20:40
shmohamudlet a = true20:40
scooperThanks Programmer20:40
shmohamudlet b = false20:40
shmohamudif(a && b){ */does this run /*} 20:40
shmohamudWill this a && b evaluate to true or false?20:41
scooperno20:41
scooperit will result to false20:41
shmohamudPerfect.20:41
scooper&& is the same as and in python20:42
shmohamudhow about if(!a && !b) ?20:42
scooperit mean the two operand most be the same 20:42
scooperyes20:42
shmohamudnot necessarily, sometimes syntax is the same between languages but they can mean different things20:42
shmohamudtrue or false ?20:43
scooperit is the opposite for the previous question so this will result to true20:43
scooperlet me test the code and see20:43
shmohamudtest and let me know what you get20:43
scooperUncaught SyntaxError: Unexpected token '?'20:46
shmohamudhmm. want to share your code?20:47
scooperyes20:47
scooperet a = true20:47
scooperundefined20:47
scooperlet a = true;20:47
scooperundefined20:47
scooperlet b = false;20:47
scooperundefined20:47
scooperif (!a && !b) ?20:47
scooperlet a = true20:48
scooperundefined20:48
scooperlet a = true;20:48
scooperundefined20:48
scooperlet b = false;20:48
scooperundefined20:48
scooperif (!a && !b) ?20:48
shmohamudyou can't have the question mark there for JS. Are you trying to do a ternary?20:48
scooperok it work now20:51
scooperlet a = true;20:51
scooperundefined20:51
scooperlet b = false;20:51
scooperundefined20:51
scooperif (!a && !b){20:51
scooper    console.log("true")20:51
scooper}20:51
scooperelse{20:51
scooper    console.log("false")20:51
scooper}20:51
scooperVM267:5 false20:51
shmohamudit's false. Do you see why?20:51
scooperyes20:51
shmohamudcan you try (!(a && b)) ?20:51
scooperok20:52
shmohamudfirst, what do you expect?20:52
scooperif(!(a & b)){20:54
scooper    console.log("true")20:54
scooper}20:54
scooperelse{20:54
scooper    console.log("false")20:54
scooper}20:54
scooperVM469:2 true20:54
scooperooh I didn't notice your question20:54
scooperdo you want me to explain??20:54
shmohamudDid you expect to get true?20:55
scooperyes20:56
shmohamudOk, good.20:56
shmohamudNow, what would (!true || !false) evaluate to?20:56
scooperbecause of the ! operation which turn the instruction around after execution20:56
scoopertrue20:57
scooperbut I m confusion here20:57
shmohamudcorrect20:58
scooperit was just it guess20:58
scooperI want to say something20:58
shmohamudYes, what's up?20:58
scooperthe pipe signal mean or in js which mean run the program as one of the evaluation is true right20:59
scooper*sign20:59
scooperthe pipe sign mean or in js which mean run the program as long one of the evaluation is true20:59
shmohamudthe pipe operator is the "OR" operator, yes. It means if either of the Booleans are true, return true20:59
scooperso the exclamatory sign turn the expression around right??? 21:01
shmohamudYes, it means "NOT"21:02
scooperOK understood21:02
shmohamudwhat does (!!true) evaluate to?21:03
scooperhmmm not sure till I execute this program in my console21:03
scooperbecause of the double exclamatory sign21:04
shmohamudtry taking it one piece at a time. What does !true evaluate to?21:04
scooperwhen something is already true, then you add the exclamatory sign it will change it to false21:05
shmohamudyes21:05
shmohamud!true evaluates to false21:05
shmohamudthe exclamatory sign is called the "Bang" operator21:05
scooperbut the double exclamatory sign got me confuse21:05
shmohamudthat's fine, let's break the problem down. What is !true evaluate to?21:06
scooperfalse21:06
shmohamudperfect21:06
scooperok21:06
scooperI think I grab it now21:06
shmohamudso now we can substitute !true with false. So it becomes !false.21:07
shmohamudSo, what does !!true evaluate to?21:07
scooperat final out put it will be true21:08
shmohamudperfect!21:08
shmohamudSo, can you write me an if statement that will always run and console.log("This is always true")?21:09
scooperwith the previous code??21:09
shmohamudno, however you can think to make sure it's always true21:10
scooperooh ok got you21:10
shmohamudit's not a trick question don't worry ;)21:11
scooperif (num1 && num2) {21:14
scooper    console.log("This is always true")21:14
scooper}else{21:14
scooper    console.log("This is not always true")21:14
scooper}21:14
scooperVM321:2 This is always true21:14
shmohamudwhat're num1 and num2 equal to?21:15
scooperno it's not a tricky question programmer21:15
scooperboth value are equal to 2021:15
shmohamudok, is there another way you can make sure it's always true, in one word?21:16
scooperhmmm, trying to analyze your question21:17
scooperok let me try it another way round21:18
*** shmohamud has quit (Remote host closed the connection)21:20
scooperif (num1){21:21
scooper    console.log("This is always true")21:21
scooper}21:21
scooperlet num1 = 20;21:21
scooperundefined21:21
scooperif (num1){21:21
scooper    console.log("This is always true")21:21
scooper}21:21
scooperVM173:2 This is always true21:21
shmohamudI disconnected. Did you paste your solution?21:22
scooperdid you see the code??21:22
scooperyes21:22
shmohamudplease paste again21:22
scooperlet num1 = 20;21:22
scooperundefined21:22
scooperif (num1){21:22
scooper    console.log("This is always true")21:22
scooper}21:22
scooperVM173:2 This is always true21:22
shmohamudgood job. Now what if you put "true" instead of num1?21:22
scooperok let me give it a try21:23
scooperlet letter = true;21:24
scooperundefined21:24
scooperif (letter){21:24
scooper    console.log("This always true")21:24
scooper}21:24
scooperAre you  still there Sahnun???21:25
shmohamudues21:25
shmohamudyes21:25
scooperis that ok??21:26
shmohamudyup that works. Do you need to define "letter" or could you put true directly into the condition?21:26
scoopertrue will work21:26
shmohamudyes21:26
scooperbecause it a boolen expression21:27
shmohamudyou normally won't want a conditional that always evaluates to true but it's nice to know so you can see that underneath the variables is always true or false21:27
scoopershould I do it now21:27
scooperI understand21:27
shmohamudSo in Javascript, we have three types that evaluate to false21:28
shmohamudNull, NaN and undefined21:29
shmohamudif you put the integer 0 it will also evaluate to false21:29
shmohamudif you have an empty string "" or 21:29
shmohamud'' it will also be false21:29
shmohamudFor homework, I want you to write me an if else statement that runs based on using the Bang operator (!) and Null.21:30
shmohamudCan you do that?21:30
scooperYes21:31
scooperI will try21:31
shmohamudperfect. Do you have any questions for me before we call it a day?21:31
scooperyes21:31
shmohamudlet's hear it21:31
scooperIn JS === equal is use to check for data type and value right??? while double == is use to only check for type right?21:33
shmohamudReally good question21:34
shmohamudSo, the difference is that one checks for the value and type, you're correct21:35
shmohamudif(10 == "10) will evaluate to true21:35
shmohamudbut if(10 === "10") will evaluate to false21:35
shmohamudbecause it would be both the Type and Value equal. So you're correct, does that help?21:36
shmohamuddouble equal is called "loose equality" and triple equal is "strict equality" 21:36
shmohamudThe == operator performs a loose equality comparison that performs type coercion if necessary to make the comparison possible. The === operator, on the other hand, performs a strict equality comparison that does not perform type coercion and requires the operands to have the same type (as well as the same value).21:37
shmohamuddoes that help?21:37
scooperyes it will take time before tomorrow to sink21:38
scooperSahnun should I continue reading the JS book I send you all you will give me a js book???21:38
shmohamudFor now, keep using the JS book you're using. I will look into alternatives before Monday.21:39
shmohamudThe best book is Eloquent Javascript but it's not free last I checked21:39
scooperI need an advice before you leave21:40
scooperhow much it cost???21:40
shmohamudWhat's the advice about? Sure21:41
shmohamudIt's free21:42
shmohamudhttps://eloquentjavascript.net/21:42
shmohamuduse this book to practice, it's one of the best!21:42
scooperThough I m learning JS with you but I m still studying or reading my python book Jeffery give me, is that a good idea to be between two languages at the same time??21:43
shmohamudWhy don't you stop Python and focus full time on JS with me?21:43
shmohamudI am not a Python expert, I'm a JS expert21:43
shmohamudSo, I can help with Python but it wouldn't be as useful because I'm a professional JS developer not Python21:44
shmohamudMy suggestion is to learn one at a time. It's hard enough to learn one. Once you learn one very well, the next one will be MUCH easier.21:45
shmohamudWhich one do you want to focus on?21:46
scooperJS for now but still love python21:46
shmohamudGood plan. Python will be waiting for you. Maybe you will love JS even more :)21:47
shmohamudalright, any last questions before we call it a day?21:48
scooperI love JS to admit it something I really want to learn previous, but the two language seem power since they are the programming language now21:48
scooperno21:48
scooperI m done21:48
shmohamudboth languages are powerful. JS is required to be a successful web developer, though. 21:49
shmohamudIt's the language of events, all the clicks, keypresses, mouseovers of a user fire events written in JS21:49
shmohamudWhen shall we meet next? Sunday or Monday?21:50
scooperOur schedule is Monday to Friday21:51
shmohamudOk, sounds good21:51
scooperMy girl is complaining about my programming time, so I promise to be with her on Sunday21:51
scooperplease paste my question here again21:52
shmohamudHey, family first, programming second. She won't complain when you're a professional software engineer I'm sure :)21:55
scoopersure21:55
shmohamudFor homework, I want you to write me an if else statement that runs based on using the Bang operator (!) and Null.21:55
scooperok, thanks Programmer21:56
shmohamudyou're welcome, great job today. Enjoy your weekend, we'll link back Monday.21:56
scooperOK Programming thank for always helping me throughh21:57
scooperthrough21:57
shmohamudKeep up the good work. It's my pleasure watching you grow and gain skills.21:58
scooperACTION signing out with Sahnun still monday22:00
*** scooper has quit (Quit: Leaving)22:00
*** shmohamud has quit (Remote host closed the connection)22:00

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