*** 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 | |
ubuntourist | Client: 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/DRA | 13:13 |
---|---|---|
ubuntourist | M Registers • Uptime: 1h 21m 44s | 13:13 |
ubuntourist | Experimenting with HexChat... | 13:37 |
*** ubuntourist has quit (Quit: Leaving) | 13:41 | |
scooper | Good afternoon Sahnun | 20:31 |
shmohamud | Good evening Spencer | 20:32 |
shmohamud | Ready for a quick review before we move to some JS logical operators and conditional statements? | 20:32 |
scooper | yes | 20:33 |
shmohamud | Write me an arrow function that subtracts two numbers (a, b) and *returns* the result. | 20:34 |
shmohamud | Hint: there is more than one way to do this. | 20:35 |
scooper | const subtraction = (a,b) =>{ | 20:37 |
scooper | return c = a-b; | 20:37 |
scooper | } | 20:37 |
scooper | subtraction(10,2); | 20:37 |
shmohamud | ok, when you set that equal to testVariable = subtraction(10, 2) what does testVariable equal? | 20:38 |
scooper | 8 | 20:39 |
scooper | const subtraction = (a,b) =>{ | 20:39 |
shmohamud | Ok, perfect. | 20:39 |
scooper | return c = a-b; | 20:39 |
scooper | } | 20:39 |
scooper | testVariable = subtraction(10,2) | 20:39 |
scooper | 8 | 20:39 |
shmohamud | your function names are getting better each time. Good job using the return statement, too. | 20:40 |
shmohamud | Ok, let's have some fun with logical operators. | 20:40 |
shmohamud | let a = true | 20:40 |
scooper | Thanks Programmer | 20:40 |
shmohamud | let b = false | 20:40 |
shmohamud | if(a && b){ */does this run /*} | 20:40 |
shmohamud | Will this a && b evaluate to true or false? | 20:41 |
scooper | no | 20:41 |
scooper | it will result to false | 20:41 |
shmohamud | Perfect. | 20:41 |
scooper | && is the same as and in python | 20:42 |
shmohamud | how about if(!a && !b) ? | 20:42 |
scooper | it mean the two operand most be the same | 20:42 |
scooper | yes | 20:42 |
shmohamud | not necessarily, sometimes syntax is the same between languages but they can mean different things | 20:42 |
shmohamud | true or false ? | 20:43 |
scooper | it is the opposite for the previous question so this will result to true | 20:43 |
scooper | let me test the code and see | 20:43 |
shmohamud | test and let me know what you get | 20:43 |
scooper | Uncaught SyntaxError: Unexpected token '?' | 20:46 |
shmohamud | hmm. want to share your code? | 20:47 |
scooper | yes | 20:47 |
scooper | et a = true | 20:47 |
scooper | undefined | 20:47 |
scooper | let a = true; | 20:47 |
scooper | undefined | 20:47 |
scooper | let b = false; | 20:47 |
scooper | undefined | 20:47 |
scooper | if (!a && !b) ? | 20:47 |
scooper | let a = true | 20:48 |
scooper | undefined | 20:48 |
scooper | let a = true; | 20:48 |
scooper | undefined | 20:48 |
scooper | let b = false; | 20:48 |
scooper | undefined | 20:48 |
scooper | if (!a && !b) ? | 20:48 |
shmohamud | you can't have the question mark there for JS. Are you trying to do a ternary? | 20:48 |
scooper | ok it work now | 20:51 |
scooper | let a = true; | 20:51 |
scooper | undefined | 20:51 |
scooper | let b = false; | 20:51 |
scooper | undefined | 20:51 |
scooper | if (!a && !b){ | 20:51 |
scooper | console.log("true") | 20:51 |
scooper | } | 20:51 |
scooper | else{ | 20:51 |
scooper | console.log("false") | 20:51 |
scooper | } | 20:51 |
scooper | VM267:5 false | 20:51 |
shmohamud | it's false. Do you see why? | 20:51 |
scooper | yes | 20:51 |
shmohamud | can you try (!(a && b)) ? | 20:51 |
scooper | ok | 20:52 |
shmohamud | first, what do you expect? | 20:52 |
scooper | if(!(a & b)){ | 20:54 |
scooper | console.log("true") | 20:54 |
scooper | } | 20:54 |
scooper | else{ | 20:54 |
scooper | console.log("false") | 20:54 |
scooper | } | 20:54 |
scooper | VM469:2 true | 20:54 |
scooper | ooh I didn't notice your question | 20:54 |
scooper | do you want me to explain?? | 20:54 |
shmohamud | Did you expect to get true? | 20:55 |
scooper | yes | 20:56 |
shmohamud | Ok, good. | 20:56 |
shmohamud | Now, what would (!true || !false) evaluate to? | 20:56 |
scooper | because of the ! operation which turn the instruction around after execution | 20:56 |
scooper | true | 20:57 |
scooper | but I m confusion here | 20:57 |
shmohamud | correct | 20:58 |
scooper | it was just it guess | 20:58 |
scooper | I want to say something | 20:58 |
shmohamud | Yes, what's up? | 20:58 |
scooper | the pipe signal mean or in js which mean run the program as one of the evaluation is true right | 20:59 |
scooper | *sign | 20:59 |
scooper | the pipe sign mean or in js which mean run the program as long one of the evaluation is true | 20:59 |
shmohamud | the pipe operator is the "OR" operator, yes. It means if either of the Booleans are true, return true | 20:59 |
scooper | so the exclamatory sign turn the expression around right??? | 21:01 |
shmohamud | Yes, it means "NOT" | 21:02 |
scooper | OK understood | 21:02 |
shmohamud | what does (!!true) evaluate to? | 21:03 |
scooper | hmmm not sure till I execute this program in my console | 21:03 |
scooper | because of the double exclamatory sign | 21:04 |
shmohamud | try taking it one piece at a time. What does !true evaluate to? | 21:04 |
scooper | when something is already true, then you add the exclamatory sign it will change it to false | 21:05 |
shmohamud | yes | 21:05 |
shmohamud | !true evaluates to false | 21:05 |
shmohamud | the exclamatory sign is called the "Bang" operator | 21:05 |
scooper | but the double exclamatory sign got me confuse | 21:05 |
shmohamud | that's fine, let's break the problem down. What is !true evaluate to? | 21:06 |
scooper | false | 21:06 |
shmohamud | perfect | 21:06 |
scooper | ok | 21:06 |
scooper | I think I grab it now | 21:06 |
shmohamud | so now we can substitute !true with false. So it becomes !false. | 21:07 |
shmohamud | So, what does !!true evaluate to? | 21:07 |
scooper | at final out put it will be true | 21:08 |
shmohamud | perfect! | 21:08 |
shmohamud | So, can you write me an if statement that will always run and console.log("This is always true")? | 21:09 |
scooper | with the previous code?? | 21:09 |
shmohamud | no, however you can think to make sure it's always true | 21:10 |
scooper | ooh ok got you | 21:10 |
shmohamud | it's not a trick question don't worry ;) | 21:11 |
scooper | if (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 |
scooper | VM321:2 This is always true | 21:14 |
shmohamud | what're num1 and num2 equal to? | 21:15 |
scooper | no it's not a tricky question programmer | 21:15 |
scooper | both value are equal to 20 | 21:15 |
shmohamud | ok, is there another way you can make sure it's always true, in one word? | 21:16 |
scooper | hmmm, trying to analyze your question | 21:17 |
scooper | ok let me try it another way round | 21:18 |
*** shmohamud has quit (Remote host closed the connection) | 21:20 | |
scooper | if (num1){ | 21:21 |
scooper | console.log("This is always true") | 21:21 |
scooper | } | 21:21 |
scooper | let num1 = 20; | 21:21 |
scooper | undefined | 21:21 |
scooper | if (num1){ | 21:21 |
scooper | console.log("This is always true") | 21:21 |
scooper | } | 21:21 |
scooper | VM173:2 This is always true | 21:21 |
shmohamud | I disconnected. Did you paste your solution? | 21:22 |
scooper | did you see the code?? | 21:22 |
scooper | yes | 21:22 |
shmohamud | please paste again | 21:22 |
scooper | let num1 = 20; | 21:22 |
scooper | undefined | 21:22 |
scooper | if (num1){ | 21:22 |
scooper | console.log("This is always true") | 21:22 |
scooper | } | 21:22 |
scooper | VM173:2 This is always true | 21:22 |
shmohamud | good job. Now what if you put "true" instead of num1? | 21:22 |
scooper | ok let me give it a try | 21:23 |
scooper | let letter = true; | 21:24 |
scooper | undefined | 21:24 |
scooper | if (letter){ | 21:24 |
scooper | console.log("This always true") | 21:24 |
scooper | } | 21:24 |
scooper | Are you still there Sahnun??? | 21:25 |
shmohamud | ues | 21:25 |
shmohamud | yes | 21:25 |
scooper | is that ok?? | 21:26 |
shmohamud | yup that works. Do you need to define "letter" or could you put true directly into the condition? | 21:26 |
scooper | true will work | 21:26 |
shmohamud | yes | 21:26 |
scooper | because it a boolen expression | 21:27 |
shmohamud | you 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 false | 21:27 |
scooper | should I do it now | 21:27 |
scooper | I understand | 21:27 |
shmohamud | So in Javascript, we have three types that evaluate to false | 21:28 |
shmohamud | Null, NaN and undefined | 21:29 |
shmohamud | if you put the integer 0 it will also evaluate to false | 21:29 |
shmohamud | if you have an empty string "" or | 21:29 |
shmohamud | '' it will also be false | 21:29 |
shmohamud | For homework, I want you to write me an if else statement that runs based on using the Bang operator (!) and Null. | 21:30 |
shmohamud | Can you do that? | 21:30 |
scooper | Yes | 21:31 |
scooper | I will try | 21:31 |
shmohamud | perfect. Do you have any questions for me before we call it a day? | 21:31 |
scooper | yes | 21:31 |
shmohamud | let's hear it | 21:31 |
scooper | In JS === equal is use to check for data type and value right??? while double == is use to only check for type right? | 21:33 |
shmohamud | Really good question | 21:34 |
shmohamud | So, the difference is that one checks for the value and type, you're correct | 21:35 |
shmohamud | if(10 == "10) will evaluate to true | 21:35 |
shmohamud | but if(10 === "10") will evaluate to false | 21:35 |
shmohamud | because it would be both the Type and Value equal. So you're correct, does that help? | 21:36 |
shmohamud | double equal is called "loose equality" and triple equal is "strict equality" | 21:36 |
shmohamud | The == 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 |
shmohamud | does that help? | 21:37 |
scooper | yes it will take time before tomorrow to sink | 21:38 |
scooper | Sahnun should I continue reading the JS book I send you all you will give me a js book??? | 21:38 |
shmohamud | For now, keep using the JS book you're using. I will look into alternatives before Monday. | 21:39 |
shmohamud | The best book is Eloquent Javascript but it's not free last I checked | 21:39 |
scooper | I need an advice before you leave | 21:40 |
scooper | how much it cost??? | 21:40 |
shmohamud | What's the advice about? Sure | 21:41 |
shmohamud | It's free | 21:42 |
shmohamud | https://eloquentjavascript.net/ | 21:42 |
shmohamud | use this book to practice, it's one of the best! | 21:42 |
scooper | Though 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 |
shmohamud | Why don't you stop Python and focus full time on JS with me? | 21:43 |
shmohamud | I am not a Python expert, I'm a JS expert | 21:43 |
shmohamud | So, I can help with Python but it wouldn't be as useful because I'm a professional JS developer not Python | 21:44 |
shmohamud | My 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 |
shmohamud | Which one do you want to focus on? | 21:46 |
scooper | JS for now but still love python | 21:46 |
shmohamud | Good plan. Python will be waiting for you. Maybe you will love JS even more :) | 21:47 |
shmohamud | alright, any last questions before we call it a day? | 21:48 |
scooper | I love JS to admit it something I really want to learn previous, but the two language seem power since they are the programming language now | 21:48 |
scooper | no | 21:48 |
scooper | I m done | 21:48 |
shmohamud | both languages are powerful. JS is required to be a successful web developer, though. | 21:49 |
shmohamud | It's the language of events, all the clicks, keypresses, mouseovers of a user fire events written in JS | 21:49 |
shmohamud | When shall we meet next? Sunday or Monday? | 21:50 |
scooper | Our schedule is Monday to Friday | 21:51 |
shmohamud | Ok, sounds good | 21:51 |
scooper | My girl is complaining about my programming time, so I promise to be with her on Sunday | 21:51 |
scooper | please paste my question here again | 21:52 |
shmohamud | Hey, family first, programming second. She won't complain when you're a professional software engineer I'm sure :) | 21:55 |
scooper | sure | 21:55 |
shmohamud | For homework, I want you to write me an if else statement that runs based on using the Bang operator (!) and Null. | 21:55 |
scooper | ok, thanks Programmer | 21:56 |
shmohamud | you're welcome, great job today. Enjoy your weekend, we'll link back Monday. | 21:56 |
scooper | OK Programming thank for always helping me throughh | 21:57 |
scooper | through | 21:57 |
shmohamud | Keep up the good work. It's my pleasure watching you grow and gain skills. | 21:58 |
scooper | ACTION signing out with Sahnun still monday | 22: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/!