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

*** mulbah has quit (Ping timeout: 480 seconds)01:36
scooperGood evening Shmohamud01:39
mulbah07_Hello scooper01:40
scooperGood morning mulbah01:40
scooperShmohamud01:40
scooperyou didn't give your feedback on the JS book I send you01:41
*** shmohamud has quit (Remote host closed the connection)01:43
shmohamudHello scooper01:43
shmohamudHello mulbah01:43
shmohamudScooper I haven't had a chance to take a look but I promise to this weekend.01:44
mulbahHello shmohamud01:44
shmohamudMulbah do you want to join our Javascript session? We're starting from the fundamentals01:44
mulbaheveryday01:45
shmohamudperfect01:45
shmohamudScooper, are you ready?01:45
scooper+101:45
shmohamudMulbah, how much JS do you know?01:45
mulbahnone01:45
shmohamudOk, how much Python do you know?01:45
shmohamudScooper, do you know how to write a for loop in javascript?01:46
mulbahwell I can say some 01:46
scooperlet me give it a try, before I do let me say something first01:46
shmohamudOk, can you write me a for loop in python that prints numbers 1 to 101?01:46
shmohamud^ mulbah01:47
shmohamud+1 scooper01:47
mulbahme01:47
shmohamudyes, write can you write a for loop in python that prints numbers from 1 to 101?01:48
scooperI m using the console to write my JS code and it can be frustrate because the console is just like the shell code I now save01:48
mulbahyeah01:48
scooperonly it run so I might be a little bit smooth making sure to rewrite my code every time I make a mistake in the console..01:49
shmohamudwhat's wrong with the console scooper?01:49
shmohamudI don't get the issue01:49
scooperI mean01:50
shmohamudMulbah - please write it01:50
mulbahfor i in range (1, 102):01:50
mulbahprint(i)01:50
shmohamudgood job Mulbah. 01:50
scooperI m using the console to write my JS code. Since it's not an IDE I might be a little bit slow01:50
scooperBecause I m trying to make sure I get the rightful result before posting it here with you....01:51
shmohamudCan you write me a python function called reverse_string that reverses all the characters in a string. The signature should be reverse_string(str) and it should print the reversed string01:51
mulbahThanks shmohamud01:51
shmohamud^ mulbah01:51
mulbahyeah01:51
shmohamudGot it Scooper, take your time, code is not something to rush, it's better to be slow and careful.01:52
scooperAre you ready now???01:52
scooperwhat the question was???01:53
shmohamudThe console will be good practice because it forces you to learn the syntax without aid01:53
shmohamudScooper, I want you to write me a function declaration in JS. Call it helloWorld and have it print "Hello World"01:53
scooperok01:54
mulbahshmohamud it's everyday your carry on this teaching01:54
shmohamudI'm available everyday we just have to find a time that works for everyone01:55
mulbahas for me I'm available anytime01:56
mulbahso another question there for me01:56
shmohamudOk, during Saturday meeting lets make an agenda item to find a time that works for everyone who wants to learn JS01:56
mulbahThat will be more helpful for the web develop team01:58
shmohamuddefinitely02:01
scooperfunction helloWorld(message);{02:01
scooperconsole.log("Hello World")02:01
scooper}02:01
scooperhelloWorld():02:01
scooperthis code is giving me error02:01
shmohamudshould there be a semicolon after the (message)?02:01
scooperthat is only thing my brain can produce right now02:01
shmohamudyou're very close02:01
scooperhmmmm02:02
scooperlet me try again02:02
shmohamudalso, what is the error message saying? Can you write it here?02:02
scooperfunction helloWorld(message){02:04
scooper console.log("Hello World")02:04
scooper}02:04
scooperhelloWorld();02:04
scooperVM607:2 Hello World02:04
scooperundefined02:04
scooperthanks a run now02:04
shmohamudany errors?02:04
scooperno02:04
scooperit run02:04
shmohamuddo you see something that should be removed from the function definition?02:04
scooperno02:05
shmohamudThere's a golden rule in programming "no unused variables"02:05
scooperbut02:05
shmohamudIf you don't need a variable/parameter, don't declare it. Do you see any unused parameters in your function?02:05
scooper"message"02:06
scooperwill my function still run if I remove message??02:06
shmohamudwell, are you using message anywhere in the function?02:06
scooperfrom my python point of view, I m using message as a parameter02:07
shmohamudbut are you using it anywhere in the function?02:08
scooperthat why I had "message" after the function was defind02:08
scooperyes02:08
shmohamudWhere are you using message in the function?02:08
scooperI m using message as an alien for "Hello World"02:09
shmohamudWhat line are you actually using it though?02:09
shmohamud......02:09
scooperconsole.log(here)02:10
scooperin the parenthesis02:10
shmohamudBut you wrote "Hello World" you don't put "message" in there...02:10
scooperShmohamud02:10
shmohamudconsole.log(message) is different from console.log("Hello World") - do you see that?02:10
scooperI mean message is serving as a parameter why "Hello World" which is a string is serving as an argument02:11
scooperjust like python, when you declare a function with a paremeter you need to put in an argument when it being call02:12
scooperthat is the logic I was using here too02:12
shmohamudSo here's the thing02:14
shmohamudyou're correct, message is a parameter02:15
shmohamudwhen you call the function, did you call it with "Hello World" as the message or did you call it with no arguments?02:15
scooperI called the function by it name which happen to be "helloWorld"02:17
shmohamudok, but helloWorld("Hello World") is different from helloWorld() right? One of them isn't called with any argument. Do you see that?02:17
scooperOk I understand what you mean now02:18
shmohamudExplain what I mean in your own words02:18
scooperyou are to say I didn't put the value of "hellWorld(); in the parenthesis when I call the function right??02:19
scooperyou are trying to say02:20
shmohamudyes, and do you see why message is not needed?02:20
scooperyes02:20
shmohamudwhy not?02:20
scooperbecause the func didn't have an argument when it was call02:21
shmohamudyes, that's one way to understand it.02:23
shmohamudBut even simpler: we're not using message so we don't need to have it as a parameter/argument02:24
shmohamudIn programming, you want to only declare parameters if you _use_ them02:24
shmohamudSo, can you remove message parameter and run it and let me know if it breaks?02:25
scooperok02:25
shmohamudmulbah you there?02:26
scooperfunction helloWorld(){02:27
scooperconsole.log("Hello World")02:27
scooper}02:27
scooperhelloWorld();02:27
scooperVM349:2 Hello World02:27
scooperundefined02:27
shmohamudScooper I've got to go02:29
scooperOK thanks02:29
shmohamudFor homework, write me a JS function that uses a parameter (message) and prints _that_ message out instead of hard coding "Hello World02:29
scooperit' was wonderful learning with you today02:30
shmohamudTalk to you soon.02:30
shmohamudWonderful learning with you too :D02:30
scooperok..02:30
scooperACTION signing out for now02:31
mulbahyeah02:32
mulbahI'm here02:32
*** scooper has quit (Quit: Leaving)02:33
mulbahshmohamud I'm here02:34
*** shmohamud has quit (Remote host closed the connection)02:35
*** mulbah has quit (Ping timeout: 480 seconds)02:49
*** shmohamud has quit (Ping timeout: 480 seconds)03:05
*** shmohamud has quit (Remote host closed the connection)04:40
superoo_-_https://www.youtube.com/watch?v=sqSA-SY5Hro06:03
superoo_-_These rich men north of Richmond06:03
superoo_-_Lord knows they all just wanna have total control06:03
superoo_-_Wanna know what you think, wanna know what you do06:03
superoo_-_And they don’t think you know, but I know that you do06:03
superoo_-_‘Cause your dollar ain’t shit and it’s taxed to no end06:03
superoo_-_‘Cause of rich men north of Richmond06:03
superoo_-_irc.supernets.org #superbowl06:03
superoo_-_superoo_-_ LittleWebster06:03
*** superoo_-_ has left #novawebdev (Glined: User has been banned from the network.)06:03
*** shmohamud has quit (Ping timeout: 480 seconds)06:49
GapHello jeff 09:55
Gapsorry for the i didn't been around for like month, it's was because i have lot to study. It was because since we started C programming for the past three month i full with stress malloc and pointer, other project but hopefully next month i'll focus to finish everything in the gasp sheet, please10:00
*** tboimah has quit (Quit: Leaving)10:41
*** fkoikoi has quit (Ping timeout: 480 seconds)10:54
*** shmohamud has quit (Ping timeout: 480 seconds)11:50
mulbahGood morning Mr. Cole13:06
ubuntouristhi mulbah 13:06
ubuntouristHow are you feeling?13:06
mulbahGood now and you 13:07
ubuntouristI got a vaccine and... an infection from the vaccine. (I have been getting shots regularly all of my life without any ill effects, but now twice I have contracted cellulitis.13:08
ubuntouristSo, at 10:00 my time, I need to take a very short break to swallow my antibiotics.)13:09
mulbahI'm sorry for that Mr. Cole13:09
mulbahAlright13:09
ubuntouristBut, it seems to be clearing up quickly.13:09
ubuntouristAnyway, have you been reading the IRC logs to see what we've been up to?13:10
ubuntouristAlso, has tboimah been sharing the e-mails about presenting for Jeff's class? 13:11
mulbahJeff said that will not be necessary we can continue with our study13:12
ubuntouristjelkner gives me mxed messages... OK, never mind then. (He had been interested in both "tmate" and "script" / "scriptreplay" I thought.)13:14
mulbahhttps://irclogs.novawebdevelopment.org/%23novawebdev/2023-10-03.log.html13:14
ubuntouristThanks. 13:14
ubuntouristSo. A few sessions ago, I typed a short Bash program for tboimah, but I accidentally made a mistake.13:15
ubuntouristInstead of fixing it, I worked with tboimah to get him to find and fix the problem himself.13:16
ubuntouristAre you caught up with that and did you understand the mistake and the correction?13:16
ubuntourist(If not, it's a very short bit of code and we can do it together..)13:16
mulbahno13:17
ubuntouristOK, liet's redo it.13:17
mulbahsure13:18
ubuntouristssh 74Er6XBZDrhMMHHenAFHkLuVv@lon1.tmate.io13:18
ubuntouristOne thing I did not mention to tboimah but you can share it with him:13:20
ubuntouristWe talked about "permissions" and making a program "executable" with setting the "x" permission, you remember.13:20
mulbahyeah13:21
mulbahI remember13:21
ubuntouristWhen the "x" is set, the filename is displayed in green. (That's not universal, but we've been talking about ~/.profile 13:22
ubuntouristns ~/.bashrc and how there are standard default templates in /etc/skel for new users.13:22
ubuntouristSomewhere in those files are the instructions that say "print executable filenames in green when the ls command is used.)13:23
ubuntouristAnway, "oops" is a short Bash program. But it does not contain the special "shebang" comment at the top13:23
ubuntouristthat would let the operating system know "Oh! It is for Bash to read, not Python, or some other interpreter".13:24
ubuntouristAlso, the execution bit -- the "x" -- is not set.13:24
ubuntouristBut, like Python, we can put a command before the filename in order to run it even without the "shebang" or the executable "x" set.13:25
ubuntouristThe command "source" means "Interpret the following argument as a Bash program".  And there is an alias for "source". It is simply a period.13:27
ubuntourist(I could have typed ". oops" or "source oops" or 13:28
ubuntouristI could have changed the permission to add "x" and inserted a line at the top of the file "#!/bin/bash" and then to run, type "oops" without period or "source")13:29
ubuntouristOK.13:29
ubuntouristOnward. Just looking at the screen without touching your keyboard, can you see what's wrong? (You do not need to13:30
Gaphi can you please tell me what sort of project you guys working on, i have been away for a while13:30
ubuntouristscroll or type anything. All the information you need is on the screen.)13:30
ubuntouristGap, this is a separate group: This is just me, tboimah and mulbah.13:31
ubuntouristGap, we'te not working on any projects. We're studying systems administration.13:32
Gapoh i though it's was for the python people13:32
Gapsorry for the inconvienene13:33
ubuntouristmulbah, it's not the same as a python script but it is quite similar, and you should be able to see parallels13:33
ubuntouristthat may help you identify the problem.13:34
tboimahHello Guys sorry i am late13:34
ubuntouristtboimah, hi. My medication is workiing and I'm feeling better than monday.13:34
tboimahwow! that good to hear13:35
ubuntouristtboimah, We're reviewing "oops" -- the mistake you fixed with my mistake last time.13:35
tboimahAhhh okay13:35
ubuntouristI am waiting for mulbah to study and respond.13:35
Gap@tboimah what's new can you please give me update regardless of my absent for a while13:36
tboimahNo bad news bro13:36
tboimahBut you can massage me privately because ubuntourist, mulbah and I are having class here.13:37
ubuntouristWe're on the server, but please don't type anything into the screen or resize the screen. I want to keep13:37
Gapthe sever your opened for me have not been going through, i try sorting the link on crome but haven't connecting to the site13:38
ubuntouristwhat is present displaying as is and resizing messes with it..13:38
Gap@https://git.mcssliberia.org13:38
Gapis this link wrong or what13:38
ubuntouristACTION is waiting for mulbah to say something...13:40
mulbahMr. Cole I'm not understanding the error13:40
ubuntouristOK. So let's take it one line at a time. Can you explain the parts of the first line? Think about it the same way you would think about13:41
ubuntouristPython's equivalent line.13:41
mulbahokay13:43
ubuntourist(We're looking at the five lines that I showed with "cat oops". "oops" is the 5-line Bash program. So the first line of that is what we're looking at.)13:43
mulbah"filename" is an interable in python13:45
mulbahso its say 13:45
ubuntouristGood. It is an iterable in Bash too.13:46
mulbahmake filename refare to everything in *13:46
mulbah"refer"13:47
ubuntouristActually, let me correct that: "filename" isn't the iterable in either. But the "for" loop "iterates" over an iterable.13:47
ubuntouristThe "*" is the iterable here. But your analysis is correct so far.13:47
ubuntouristIn Bash, indentation doesn't matter. So for the "block" of the Bash "for" loop, you need to surround it with "do" and "done"13:48
ubuntourist(I did not need to indent my code, it is just more readable that way.)13:49
ubuntouristSo, you've got a "for" that is iterating over all files (with the "*" wildcard). What next?13:49
ubuntourist(You can skip the "do" and "done" because I've just explained that they are only there to mark the start and end of the block.)13:51
mulbah print "The next line will print a filename"13:52
mulbahThat is in python13:52
mulbahbut for bash13:52
mulbahyou say echo13:53
ubuntouristYep. (In Python you'd change the "echo" to "print" and use "(...)". Exactly right.)13:53
ubuntouristNext line....13:53
mulbahit says13:53
mulbah$ means end of line right?13:55
mulbahi this it should have been: "echo i$13:56
*** Gap has quit (Ping timeout: 480 seconds)13:56
ubuntouristUnfortunately, this is why there is so much to remember that you need great notes for yourself. "$" means end of line when13:56
ubuntouristwe are working wiht regular expressions. Here, we are not, and "$" means something else...13:56
ubuntouristACTION takes a very short break to swallow pills...13:57
ubuntouristACTION is  back13:59
mulbahTo be real i don't know it mean here13:59
mulbahthe $ 14:00
ubuntouristGo way back to when we were playing around with "export ..."14:00
ubuntourist(and "printenv")14:01
ubuntouristRemember that there was another way to say "~" or "/home/mulbah/" ...14:01
ubuntourist(Also remember that "oops" is BROKEN. We're trying to fix a mistake that I accidentally made.)14:03
mulbahoh I think the $ refer to the home directory 14:04
ubuntouristmulbah, not by itself... but you're going in the right direction.14:04
ubuntouristOK. Stop a minute, and tell me what you think the output of my program SHOULD be. 14:05
ubuntouristDon't think about how to fix it, think about what is displayed when I run it, and why it is not doing what it says it will do.14:05
ubuntouristWhat is missing from the output?14:06
mulbahIt will print "The next line will print a filename" and the home directory14:06
ubuntouristI'm going to type a new one.... Watch.14:07
ubuntouristWhat went wrong?14:08
mulbahecho print the line four times14:09
mulbahbecause of 1, 2, 3, 414:09
ubuntouristBut it said it was going to print a number... It did not print any numbers.... Why not?14:10
ubuntouristWhat is wrong with the python code on the screen?14:11
mulbahbecause you didn't echo something14:12
mulbahor print something14:12
ubuntouristWhat is wrong with the Bash code on the screen?14:12
tboimahubuntourist should i answer the question so that we can move on14:13
ubuntouristtboimah, I'd prefer you did not. 14:13
mulbahecho filename14:13
ubuntouristmulbah, close, but missing one character.14:14
tboimahOkay i am waiting14:14
mulbahecho "filename"14:14
ubuntouristmulbah, Nope. That will just print the word "filename".14:14
ubuntouristtboimah, (I have had to repeat things for you in the past. It is better for each person to come to their own understanding, so that it will be retained.)14:15
tboimahsure14:15
mulbahfor filename in *14:16
mulbahdo14:16
mulbah    echo "filename"14:16
mulbah    echo $i14:16
mulbahdone14:16
ubuntouristWhy did the code I just ran not print any numbers?14:17
mulbahbecause you didn't tell it to print something14:18
mulbahor echo "something"14:19
ubuntouristIn Bash, we need a special way to refer to variables that we use, after we define them...14:20
ubuntouristOK, tboimah go ahead.14:20
tboimahokay the code is not print number because echo $i is undefine14:21
mulbahecho $filename14:21
ubuntouristmulbah, you got there.14:21
tboimahit should have been echo $ something14:22
ubuntouristBINGO14:22
tboimahinstead of echo $i14:22
ubuntouristIn Bash you can create environment variables a few different ways, similar to Python.14:23
mulbahI remember when you said that there is special way to refer to variables14:23
ubuntourist(Except that sometimes you cannot use spaces.)14:23
*** shmohamud has quit (Remote host closed the connection)14:23
ubuntouristSo "for blablabla in ..." creates a vaariable named blablablah but to use it, you need the $ prefix.14:24
ubuntouristSo, I know tboimah was pastiently sitting while we were eating up time, but we're going to rush on to that script and README that I made.14:25
tboimahokay14:25
ubuntouristWe have this ugly bit of code...14:26
ubuntouristfor filename in $(locate ly    | \14:26
ubuntourist                  grep "\.ly$" | \14:26
ubuntourist                  grep kjcole  | \14:26
ubuntourist                  egrep -v "(/\.|FrayedKnotArts|engraving|rosegarden|_lilypond|sphinx-notes|\14:26
ubuntourist2.24.2)");14:26
ubuntouristat the start of the thing we left off woring on.14:27
ubuntouristQuick review: I was searching for all of the files that ended with the file extension ".ly"14:27
ubuntouristWell, but I only wanted files owned by me.14:28
ubuntouristAnd I only wanted files that I created myself, not files that I downloaded from14:28
ubuntouristsomewhere else. So, there were directories to eliminate.14:28
ubuntouristWe constructed an elaborite set of filters:14:29
ubuntouristlocate ly | grep "\.ly$" 14:29
ubuntouristcreates a quick list of files with "ly" anywhere in the name -- like "plymoth" but then filters that list14:30
ubuntouristfor anything that ends with ".ly"14:30
ubuntouristthen we added a filter to only find lines with ly ending with .ly that also had "kjcole" somewhere in them.14:31
ubuntouristthen we filtered out a bunch of files using the fancier "egrep". The "-v" eliminates matches.14:32
ubuntouristSo DON'T match any lines that have "/." -- hidden directories, or "FrayedKnotArts" or "engraving" or "rosegarden" or ... etc, etc.14:33
ubuntouristNow... here's where it gets interesting:14:34
ubuntouristWe've created an iterable... Its's a big long list of files, one filename per line.14:34
ubuntouristThe power of the the Bash $ -- wihich is different from the regular expression $ -- comes in.14:35
ubuntouristThis is IMORTANT!14:35
ubuntouristWe can wrap a command, or a set of commands inside of $( ... ) and the results become an iterable list !!!14:36
ubuntouristWRITE THAT DOWN somewhere! It's what we have been working up to very slowly.14:36
ubuntouristACTION needs a quick bathroom break. Think about what I just wrote and either ask questions or explain it back to me in your own words.14:38
ubuntouristbut write done wihen finished so you don't type over each other..14:38
ubuntouristACTION is back again.14:41
ubuntouristACTION waits for thoughts, questions, etc. but will say a little bit more14:43
mulbahwell no question14:44
ubuntouristThink of piped commands as people working together, like in a game, or farming, or building something together..14:44
ubuntouristeach person does part of a task and hands the "product" to the next person to do the next task.14:45
ubuntouristSo we have "locate" which quickly searches a  database (that must be periodically  updated with "sudo updatedb") full of filenames.14:45
ubuntouristIt produces a list, which is handed off to grep, which shortens the list, and to grep again and again each time narrowing the list.14:46
ubuntouristTogether $(locate ... | grep ... | grep ... | egrep ...) is the whole "product". Each player did their own part.14:47
ubuntourist(And we're not limited to locate and grep. Any program that produces output in a format that can be used as input by some other14:48
ubuntouristprogram can be used in this way.)14:48
ubuntouristNow its:14:48
ubuntouristfor variable in $(locate ... | grep ... | grep ... | egrep ...)14:49
ubuntouristSo, we can take each file name from the filtered list and act on it.14:49
ubuntouristWe could ... rename each file in the list, or delete each file in the list, or open them one by one in nano, so that we could14:50
ubuntouristedit them by hand.14:50
ubuntouristSuppose you had a group of students, they each created a report in a file. The teacher has told all of the students14:52
ubuntouristthat they can choose whatever filename they want, but it must end with ".txt"  And maybe the file name should include the date.14:52
ubuntouristSo, /home/tboimah/readme-2023-10-06.txt  and /home/mulbah/homework-2022-05-27.txt and /home/tboimah/x-2021-12-15-hello.txt14:54
ubuntouristall match.14:54
ubuntouristAnd there are 30 more files or 100 more files like that.14:55
ubuntouristNow, you want to read them, one by one. You could create a complex filter and a for loop,14:55
ubuntouristand run each one through "most"14:55
ubuntouristeach would open and you could read. When you type "Q" to quit "most", the next file from the iterable list would14:56
ubuntouristbe selected and opened.14:56
ubuntouristThis is an invredibly important concept for systems administrators (and others).14:57
ubuntouristHOMEWORK: Contiinue with your readings. (I mentioned on Monday that I think we're somewhere around chapters 11 and 13,14:57
ubuntouristbut I am skipping the chapter on the "vi" editor. because I prefer other editors. You should read that on your own and ask Jeff14:59
ubuntouristquestions about "vi" beccause it is his favorite editor.14:59
ubuntouristOTHER HOMEWORK: Try creating small Bash scripts with $( ... | ... | ... )  iterables in a "for" loop,15:00
tboimahokay15:00
*** tboimah has quit (Quit: Leaving)15:00
ubuntouristYour book should be moving that direction. You may  need to skip ahead in the book to get to it.15:00
ubuntouristBut the book has much of this in it.15:01
ubuntouristBye for now!15:01
mulbahokay15:02
mulbahThanks for the teaching today15:02
mulbahget well soon15:02
*** ubuntourist has quit (Quit: Leaving)15:03
*** mulbah has quit (Ping timeout: 480 seconds)15:50
*** shmohamud has quit (Remote host closed the connection)19:43
scooperHello Shmohamud19:55
shmohamudHi Scooper19:56
shmohamudare you ready for today's lesson?19:56
scooperyes19:56
scooperbefore we begin19:57
shmohamudLet's start with some review. Write me a function declaration helloWorld that prints out "Hello World"19:57
scoopercan we set a fix time on meeting here19:57
shmohamudyes, Monday through Friday at 8:30PM works for me19:57
scooperok19:57
shmohamudToday I finished work early so I could log on19:58
shmohamudusually I will not finish work early19:58
scooperfunction helloWord(){20:00
scooperconsole.log("Hello World")20:00
scooper}20:00
scooperhelloWorld();20:00
shmohamudBeautiful20:01
shmohamudWhy didn't you add the message parameter like last time?20:01
scooperbecause you said20:02
scooperevery variable that is use in a most have a role20:02
shmohamudYes, exactly. We weren't using the message parameter so it is bad practice to include it in the function20:03
shmohamudNow, can you rewrite the function to accept a name parameter, and print "Hello {name}"?20:03
scooperlet me give a shot20:04
scooperfunction person(name){20:06
scooperconsole.log("Welcome " + name)20:06
scooper}20:06
scooperperson("Shmohamud")20:06
shmohamudclose20:06
shmohamudI asked you to rewrite the function with the same name. So keep helloWorld(name)20:07
scooperok20:07
shmohamudAnd I also asked the console to log "Hello " + name"20:07
shmohamudwith programming, you must read requirements carefully. Much of the solution to a problem comes from deeply understanding the problem to begin with20:08
shmohamudthat's why I'm being hard on you now, so you build the right habits as a professional programmer20:09
scooperunction helloWorld(name){20:09
scooperconsole.log("Hello " + name)20:09
scooper}20:09
scooperhelloWord("Shmohamud");20:09
shmohamudPerfect20:09
shmohamudOk, so now we know about function declarations and we learned to never include unused variables in a function definition20:10
shmohamudThere are two other ways to define functions in javascript20:10
shmohamudconst helloWorld = () => console.log("Hello World")20:11
shmohamudthat's called an arrow function20:11
scooperarrow funcntion20:11
shmohamudyes20:11
shmohamudthe above is also called an arrow function expression20:13
shmohamudbecause we declare the function name and set it equal to the function itself. Does that make sense?20:13
scooperyes but question20:14
shmohamudyes20:14
scooperAs for variable declaration in js we have let, var const and it have it difference between. is the a difference between the three function definition??20:15
shmohamudGreat question!20:16
shmohamudYes, there's a difference20:16
shmohamudBut it's a bit complicated.20:16
scooperok20:16
shmohamudArrow functions do not "hoist" which means anywhere in the program (even before declaring it) you can call that function20:17
shmohamudFunction declarations are "hoisted" which means you can use them before or after they're declared.20:17
shmohamudRemember usually programs are just a series of steps and the code is read from top to bottom of the script20:17
shmohamudThere are other differences but even I have to review to remember them. What's important for now, though, is to understand the syntax and be able to declare both types of functions20:18
scooperok20:18
shmohamudOk, can you write me an arrow function that takes two parameters(a, b) and adds them and then prints the result to the console?20:19
scooperlet me try20:20
shmohamuduse this syntax: () => { */do something /*}20:20
shmohamudthe curly brackets are required for arrow functions if you want to have multiple statements inside20:20
shmohamudthe function body20:20
sysadmin_I m receiving syntax error20:27
shmohamudok, can you write the error here so we can resolve it?20:27
shmohamudIt's important you learn how to read error messages properly, so we'll start going through error messages together.20:28
shmohamudSyntax error means something about the code isn't following JS syntax, but it should have "unexpected token :" or something like that20:28
sysadmin_Uncaught SyntaxError: redeclaration of var helloWorld20:28
sysadmin_    <anonymous> debugger eval code:120:28
sysadmin_please wait20:29
shmohamudredeclaration is a new error for me20:29
shmohamudOk, take your time20:29
sysadmin_let figure20:29
*** scooper has quit (Ping timeout: 480 seconds)20:32
sysadmin_Uncaught SyntaxError: redeclaration of var helloWorld20:34
shmohamudcan you share the code here?20:35
scooperconst helloWorld = (a,b) =>{20:36
scooperconsolo.log(a,b)20:36
scooper}20:36
scooperhelloWord(8+3);20:36
shmohamudthe function is correct except when you call it and when you log it20:37
shmohamudI asked you to add them together inside the function, not to pass 11 (8+3) to the function20:37
shmohamudCan you rewrite the function and make sure to pass two arguments to it (a, b)?20:38
shmohamudalso can you change the name from helloWorld to something related to what we're doing inside the function?20:38
scooperok20:38
scooperI can for now20:41
scooperI have but still I m unable to solve that challenge20:41
shmohamudwhat challenge?20:42
scooperthe instruction you give me20:42
shmohamudOk, would you like me to walk you through it?20:42
scooperyes20:42
shmohamudOk, so I asked you to write a function that takes in two parameters (a, b) and console.log the sum (a + b)20:43
shmohamudI'll call it addTwoNumbers = (a, b) => { console.log(a + b) }20:43
shmohamudcan you try that and call it with two numbers and let me know if it works20:43
scooperit run but I got NaN20:45
scooperconst addTwoNumbers = (a,b) =>{20:46
scooperconsole.log(a + b)20:46
scooper}20:46
scooperaddTwoNumbers(4 + 2);20:46
shmohamudHow many parameters do we declare in the function?20:46
scooperTWO20:46
shmohamudHow many are you calling it with?20:46
scooperTwo 4 & 220:47
shmohamudAre you sure you're calling it with two?20:47
scooperyes20:47
shmohamudIn fact you're calling it with one argument because (4 + 2) will become (6) 20:48
shmohamudSo you get NaN because you're adding 6 + undefined20:48
shmohamuddoes that make sense?20:48
scooperhmmmm20:48
scoopersound strange...20:48
shmohamudthis is important. Do you see what I mean by you're actually only passing one argument, because 4+2 becomes 620:49
shmohamud?20:49
scooperShmohamud20:50
scooperI m sorry to say this timing is not really working for me.... I usually done still up till 8pm due to that I m feeling  sleepy......20:51
shmohamudThat's fine, when is a better time for you?20:51
scooperI appreciate the effort here but can we adjust the time please.....20:51
shmohamudyes we can adjust the time20:52
scoopercan we take 4-5pm my time??? or 3:00 am my time??20:52
shmohamudI'm working 4-5pm your time but I can probably do 30m sessions during work20:53
shmohamudYou mean 12-1pm EST time (my time) right?20:54
scooperyes20:54
shmohamudi can meet you during that time during the week20:54
scooperI m appealing because my body have gotten use to early sleep20:55
scooperand waking up early20:55
shmohamudthat's understandable, I don't want to throw off your routine20:55
shmohamudLet's plan on meeting 12-1pm Monday through Friday. Just message me on WhatsApp if you can't make it20:55
scooperOk thanks for understanding20:56
shmohamudof couse20:56
shmohamudof course *20:56
scooperMean while I wil read on Arrow function and come back with a better performance next time20:56
scooperdid you see the book now???20:56
shmohamudThat sounds good. I haven't seen the book yet20:56
scooperit three minutes to 9:00pm on my side20:57
scoopercan I go to bed now20:57
shmohamudYes, sleep well and we'll continue on arrow functions Monday20:58
scooperOK thanks20:58
scooperACTION signing out20:58
*** scooper has quit (Quit: Leaving)20:58
*** shmohamud has quit (None)20:58

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