IRC log of #novawebdev for Monday, 2023-10-16

*** shmohamud has quit (Remote host closed the connection)00:55
*** shmohamud has quit (Ping timeout: 480 seconds)01:07
*** shmohamud has quit (Ping timeout: 480 seconds)01:43
*** shmohamud has quit (Remote host closed the connection)02:33
*** shmohamud has quit (Ping timeout: 480 seconds)02:48
*** shmohamud has quit (Ping timeout: 480 seconds)09:42
*** fkoikoi has quit (Quit: Leaving)10:12
*** tboimah has quit (Ping timeout: 480 seconds)10:26
*** dcammue has quit (Ping timeout: 480 seconds)12:36
*** tboimah_ has quit (Read error: Connection reset by peer)12:42
*** tboimah_ has quit (Ping timeout: 480 seconds)13:01
ubuntouristhi tboimah 13:04
tboimahGood morning ubuntourist13:04
ubuntouristI'll launch right in today... Have you been folowing the log?13:05
tboimahmulbah said that he will not be here today, because he have something to take care of.13:05
tboimahnot really because my computer screem was given problem, i thought i email on that13:06
tboimah*you13:06
ubuntouristYou did. But I thought you said that you had two problems: One was your computer screen and the problem13:07
tboimahand i just arriving at the mcss office to turing online today but i will read it after the class today13:07
ubuntouristwas that you could not get to the school. I just thought that maybe you had succeeded in going to the school eventually.13:07
ubuntouristAnyway, mulbah and I got stuck: I am trying to get back to the iidea of fields and field delimiters.13:07
ubuntouristField delimiters are sometimes also called field dividers or field separators.13:08
ubuntouristSeveral weeks ago we talked about fields and field delimiters when we way back when we were discussing13:09
ubuntouristfile ownership and file permissions. We looked at /etc/passwd and /etc/group and talked about how the data13:10
ubuntouristin those files was organized into fields.13:10
ubuntouristThis is why I want you both to take good notes: When I asked him how to split a line like13:11
ubuntouristsong_of_joy.ly:    composer = "Unknown"13:12
ubuntouristinto two fields, with the first field being the file name, he did not seem to know what field or field delimiter meant.13:13
tboimahA delimited field is a variable-length field where the field length is set based on the field's contents.13:14
ubuntouristBut previously, you both said you understood fields and field delimiters when we used "cut" with /etc/passwd.13:14
ubuntourist(I mean you understood after I explained it several sessions ago.)13:15
ubuntouristSo. The question is: Do you remember how to use cut? And what is meant by field and field delimiter?13:16
tboimahlike i said A delimited field or field delimited is a variable-length field where the field length is set based on the field's contents.13:16
ubuntouristOK. So, in a line like:13:17
ubuntouristsong_of_joy.ly:    composer = "Unknown"13:17
ubuntouristwhat is the delimiter that would split the line where I want it to split?  You've quoted a definition but does it mean anything to you?13:18
tboimahthe delimiter will be colon ":" in the sentence you just wrote13:19
ubuntouristExcellent. Maybe you can explain it to mulbah better than I can.13:20
ubuntouristI don't want to give him the answers. I want him to come to the understanding of what a field is and what a delimiter is.13:20
ubuntouristAnyway... The reason we're going back to that: We're finishing up that README and script movie I sent several weeks ago.13:21
ubuntouristI'm going to repeat myself a bit, because a lot of this is in the log from when you were unable to come. So, I'll be brief, and you can13:22
ubuntouristeither ask questions or go back and read the IRC logs that you've missed. Maybe both.13:22
tboimahokay13:23
ubuntouristSo..... You might remember: We were filtering a list of files.13:23
tboimahyeah dose file the end with extension ".ly"13:23
ubuntourist"locate ly" to find all files with "ly" in the file name (inculding names we don't want like "plymouth")13:24
tboimahsure13:24
ubuntourist"grep "\.ly$" to filter for only the ones that END with ".ly", "grep kjcole" to find only the ones I own, etc. etc.13:25
ubuntouristNow, the fun part:13:25
tboimahlet rod13:25
ubuntouristYou remember we did "for filename in *" and then used $filename as the variable.13:25
tboimahyeah, that's the for loop13:26
ubuntouristthe "*" was an iterator -- it created a list of file names that we could pluck one at a time.13:26
ubuntouristHere's the important part: We can do the same thing with the big filter we created.13:27
tboimahthat is the same name for it in python "*"13:27
tboimahokay13:27
ubuntouristInstead of using the * wildcard for "all files in this directory" 13:27
ubuntouristwe can take any command -- or group of commands -- that produces output and use those instead of the wildcard.13:28
tboimahsound intresting13:29
ubuntouristIf you take something like "locate ... | grep ... | grep ... | egrep ..." and surround it with "$(" and ")"13:29
ubuntouristyou can substitute it for the wildcard.13:29
ubuntouristfor filename in $( locate ly | grep "\.ly$" | grep kjcole | egrep -v "(frayedknot|_lilypond|...)")13:30
ubuntouristThe part  $( locate ly | grep "\.ly$" | grep kjcole | egrep -v "(frayedknot|_lilypond|...)")  is just13:31
ubuntouristthe filter we created, enclosed inside $( ... )13:31
ubuntouristTime to tmate13:32
ubuntouristssh NVGxDJURakBprzarF4RHxEACB@lon1.tmate.io13:32
ubuntouristI think I mentioned, in Bash, when you have a very long line, you can break it up for easier reading13:35
ubuntouristby adding a backslash \ to the end. So that first line is really 13:35
tboimahone line13:35
ubuntouristfor filename in $(locate ly | grep ... | grep ... | egrep ...)13:35
ubuntouristThe egrep here is eliminating directories that I don't want.  The regular expression pattern13:37
ubuntourist(xxxxx|yyyyy|zzzz)  -- where you have several values inside parenthesis and separated by the | means13:38
ubuntouristmatch xxxxx OR yyyyy OR zzzz13:38
ubuntouristand the "-v" means DON'T.13:38
ubuntouristSo egrep -v "(/\.|FrayedKnotArts|...)" means13:39
ubuntouristeliminate (don't match) files that have "/." or FrayedKnotArts or engraving or rosegarden or ...13:40
ubuntouristanywhere in the full file path.  So if there was a /home/kjcole/bla-bla-blah/FrayedKnotsArt/composition.ly it would be eliminated13:41
ubuntouristfrom the list. (It ends in ".ly" and is in a "kjcole" directory, but it also has FrayedKnotArts. So it gets kicked out.)13:42
ubuntouristOK. So now we've got this list and we're using it as an iterator.13:42
ubuntouristThe egrep after the "do" has a "-H".  Let's explore the -H for a mintue. I think the history command will let me repeat what mulbah and I did.13:43
*** tboimah has quit (Ping timeout: 480 seconds)13:44
*** fkoikoi has quit (Ping timeout: 480 seconds)13:44
tboimahsorry my connection drop13:45
ubuntouristok.13:46
ubuntouristYou type:13:46
ubuntouristegrep "qwert" README.md13:46
ubuntourist("qwert" is my "throw-away" word: It's the first five letters on the top row of the keyboard, and is usually something that does not exist.)13:47
ubuntouristSo. egrep came back with nothing. Which means?13:48
*** tboimah has quit (Remote host closed the connection)13:49
tboimahsorry oo Mr. cole the connection look bad today14:02
tboimahubuntorurist are you there14:03
ubuntouristI'm here14:04
ubuntouristI started doing something else while waiting.14:04
tboimahokay i am back14:04
ubuntouristOK. The tmate is still open. So you should be able to use the up-arrrow to re-enter the ssh command.14:06
ubuntouristOh.14:06
ubuntouristWait. you're alteady here.14:06
ubuntouristSorry.14:06
tboimahsuer14:06
tboimahsure14:06
ubuntouristI didn't know you're on.14:06
ubuntouristSo. egrep came back with nothing. Which means?14:07
ubuntourist(egrep "qwert" README.md produced no output. Which means?)14:08
ubuntouristACTION is hoping the connection is still here... If not he is going to just use e-mail for class lectures and hope for the best.14:09
tboimahthe connection is on14:10
ubuntouristThere was a question with no response. So I thought the connection was gone again.14:10
ubuntouristACTION continues to wait for an answer to  the question ".... Which means?"14:12
tboimah"qwert" is your "throw-away" word14:12
ubuntouristYeah, but I mean "When egrep does not produce output, what does that tell you?"14:13
tboimahIt pretty much means that the string you are searching for was not found14:14
ubuntouristRight.14:15
ubuntouristOK now "egrep "poet" README.md14:15
ubuntouristSo. it found some matches. Now try both commands again but this time change "egrep" to "egrep -H".14:16
ubuntouristKeep the rest of the line the same.14:16
ubuntouristSo. What changed?14:18
tboimahThe name "README.md" come at the begging of the line14:19
tboimahand it have so delimiter charater at the to[14:20
tboimah*top14:20
ubuntouristIf you use grep and egrep to search ONE file only (like we did here) it will not print a file name for matches unless you use the "-H"14:20
ubuntouristNow try the commands with "-c" instead of "-H"14:20
tboimahit count the number of line14:21
ubuntouristNow try both. "-cH" (or "-Hc". the order is not important.)14:21
ubuntouristSo, you get both the file name and the count.14:22
tboimahit print both the file name and count the line14:22
ubuntouristWhen you are looking at lots of files, it can be very helpful to know which files had NO matches. 14:23
ubuntouristSeeing "filename:0" is better than no output. 14:24
tboimahyeah14:25
ubuntourist"wc -l" either expects a file name after it, or a pipe before it. What it showed you in your second attempt was14:25
tboimahsure14:25
ubuntouristit tried to count the number of lines in a file named "egrep" and it coud not find a file with that name. Then it tried to find the number of lines in a file named "poet" and it could not find that file. Then it tried to print the number of lines in a file named README.md... and it found that one.14:26
ubuntouristAnd, if you flipped the command around, using the pipe, you would still get a wrong answer. Try:14:27
ubuntouristegrep -H "qwert" README.md | wc -l14:27
ubuntouristegrep -cH "qwert" README.md | wc -l14:28
ubuntouristegrep -cH "poet" README.md | wc -l14:29
ubuntouristegrep -cH "QWERT" README.md | wc -l14:30
ubuntouristThe reason: In the first example, where you just used the -H, egrep printed 15  lines that matched. So "wc -l" said "15"14:31
ubuntouristIn the second example, where you typed egrep -cH "poet" README.md | wc -l14:32
ubuntouristegrep produced as output14:32
ubuntouristREADME.md:114:32
ubuntouristAnd you told it to count the number of lines in the output. "README.md:1" is only one line of output.14:33
tboimahOKAY. well understood14:33
ubuntouristWhen you used "QWERT", egrep produced "README.md:0" ... which is only one line of output. So "wc -l" again said "1".14:34
ubuntouristNow, finally, getting to the example I was trying to work on with mulbah...14:35
tboimahokay let role14:35
ubuntouristegrep -H "^..To be continued" README.md14:35
ubuntouristNow, add a pipe to the end and use cut to split get only the file name. With cut, 14:37
ubuntourist"-f" follwed by a number tells which field to get and -d followed by a character enclosed in quotes says what the delimiter that separates fields should be14:38
ubuntourist(You'll need both a -f and a -d plus a field number and a delimiter.)14:39
ubuntouristNope. the -f needs a number after it and the -d needs a delimiter in quotes after it.14:40
ubuntouristClose. Very close.14:41
ubuntouristBut why did you use 6?14:42
*** shmohamud has quit (Ping timeout: 480 seconds)14:42
tboimahbecause you said that -f need a number after it, so i just suggest 614:43
ubuntouristThe field number is the number is  the number of which field you want. 14:43
ubuntouristThe field number is the number is  the number of which field you want. 14:44
ubuntouristBINGO. Almost.  It worked, but in this situation, just "1" not "-1" would have been better.14:46
ubuntouristLet's try a few experiments with that to see why14:46
ubuntouristchange the delimiter to a space    -d " " and use your -114:47
ubuntouristTry -1 then try 2 and try -214:48
ubuntourist(leave the -d " " as it is.)14:49
ubuntouristACTION stepping away for a moment.14:49
mcssguest_done14:50
*** tboimah has quit (Ping timeout: 480 seconds)14:51
ubuntouristACTION is back.14:52
tboimahyeah i done14:53
ubuntouristSo. In the first one, where we used the space as a delimiter, it did the expected thing: It divided the line by spaces, and printed everything up until the first space.14:53
ubuntouristit did that for both "1" and "-1"14:54
ubuntouristBUT, for the "2" and "-2" do you have any guess about why they are different?14:54
tboimahyeah14:54
tboimahi notice the the "-"2 means from the begging of the line to 214:55
ubuntouristBINGO.14:55
tboimahBINGO14:56
ubuntouristSo, when you use 1 or -1 it means either "field #1" or "from the beginning of the line up until field #1" . And for the first field, those two are the exact same thing.14:57
ubuntouristSo... We are almost finished with our little Bash program.14:58
ubuntouristFirst we found the file names we wanted to work with.14:58
ubuntouristThen for each of those files, we use egrep -H to print the file name, and the match.14:59
ubuntouristThe pattern here "^[[:space:]]*(poet|composer|arranger)" 15:00
ubuntouristbreaks down like this:15:00
ubuntourist^          at the beginning of the line15:00
ubuntourist[[:space:]]*    zero or more spaces15:00
ubuntourist(poet|composer|arranger)       followed by either "poet" or "composer" or "arranger"15:01
ubuntouristIn other words, find me any lines that start with any of those three words, and nothing before them except spaces.15:02
ubuntouristMatching lines would be15:02
ubuntouristpoet bla-bla-bla15:02
ubuntourist         composer bla-bla-bla15:02
ubuntourist  arranger bla-bla-blah15:03
ubuntourist                              poet15:03
ubuntouristBut not:15:03
ubuntourist# poet15:03
ubuntourist;        arranger15:03
ubuntouristI don't know who the composer is15:03
ubuntouristThose last three have the matching words, but they do not start with spaces.15:04
ubuntouristI'm going to type to speed things up a little bit.15:05
ubuntouristLook at that before hitting the ENTER, because when you press ENTER it's all going to go offf the screen.15:07
ubuntourist(When you feel like you've got the basic understanding, press ENTER.)15:08
ubuntouristAnd if you have a question, go ahead and ask before pressing ENTER.15:09
*** tboimah has quit (Read error: Connection reset by peer)15:09
ubuntouristHmmm... I must have made a mistake...15:09
ubuntouristHmmm... I must have made a mistake...15:09
tboimahdone15:09
ubuntouristOh. I know what the problem is: I didn't expand the tarball... Hold a sec...15:10
ubuntouristIt could not find any files to search because there were no ".ly" files. Now there are.15:11
ubuntouristDamn.15:11
ubuntouristI'm missing something.15:12
ubuntouristOh.... RIGHT: locate. Locate searches a database. The database has not been updated after I expanded the tarball.15:14
ubuntouristlocate still does not know that there are any files ending in ".ly"...15:14
ubuntouristHold a sec...15:14
ubuntouristOne more time...15:15
ubuntouristThat's what I was looking for..15:15
tboimahyeah BINGO15:16
ubuntouristIf you scroll left and right you will see the matches.15:16
ubuntourist;-)15:16
ubuntouristSo. All of the lines contain the full path to the file  /home/kjcole/class_notes/.../home/kjcole/.../some_file.ly15:17
ubuntouristand the matching text "       poet = ..." or "   composer = ..."   or "  arranger = ..."15:18
ubuntouristNow, we take the output of the egrep ... and filter it more.  We will ELIMINATE lines that have15:19
ubuntouristsmallCaps15:19
ubuntouristin the line.15:19
ubuntourist(grep -v "smallCaps")15:19
ubuntouristBefore we do that, let's find some examples.15:20
ubuntouristI don't want the file named "avenging_and_bright.ly" because it has "\smallCaps"15:21
ubuntouristThe problem that I started with was:15:21
ubuntouristI have lots of music files that I created. I want to change the font for the names of poets, or composers, or arrangers to15:22
ubuntouristthe "Small Capitals" font.15:23
ubuntouristBut, I have already done that for some files. So I don't need to see those files again.15:23
ubuntouristSo. Find all the LilyPond files -- (ending with ".ly") that I wrote -- (kjcole)  and not fiiles that I downloaded from someone else15:24
ubuntourist(FrayedKnotArts or rosegarden or a few other directories)15:25
ubuntouristOnce I have that list, search each file for poet composer or arranger and eliminate the files that already have the15:25
ubuntouristsmallCaps.15:25
ubuntouristUse "cut" to chop off everything except the file name        cut -f 1 -d ":"15:27
ubuntouristAnd finally, "uniq"15:27
ubuntourist"uniq" is a command that looks at a sorted list (I probably should have included a "sort" command)15:28
ubuntouristand eliminates duplicate lines. It forces the lines to be "unique".15:29
ubuntouristSee how there are duplicate lines?15:30
ubuntouristI have cut off the matching text.15:31
ubuntouristUp at the top 15:31
ubuntouristthe first three lines are all the same.15:31
ubuntouristLet's go back one step to see why.15:32
ubuntouristbaritone.ly had three matches: It had a match for poet, a match for composer and a match for arranger.15:33
ubuntouristSo three lines were printed.15:33
ubuntouristWhen I cut and kept only the file names, I have three identical lines.15:33
ubuntouristI only need to know the name of the file once.15:34
ubuntouristthe list tells me that there is at least ONE line that has a poet or composer or arranger, that does not use smallCaps.15:34
ubuntouristIt measn that I will need to edit baritone.ly and add \smallCaps to it.15:35
ubuntouristI don't need to know that informathon three times. I only need to know "baritone.ly needs editing".15:35
ubuntouristOops. baritone-scale.ly not "baritone.ly" I should read my own screen. ;-)15:36
ubuntouristIt is getting slower because it has more and more work to do.15:37
ubuntourist"sort" and "uniq" can take a long time.15:38
ubuntouristnow there is only ONE line for each file that meets my criteria.15:38
ubuntouristThe list on the screen now is the list of files that need to be edited.15:38
ubuntouristBut we're seeing those in "most" that's not very handy. We want to save the list so we can use it in another Bash program.15:39
ubuntouristInstead of "done | most" which sends all of the output into "most" for viewing,15:40
ubuntourist"done > add_smallcaps.txt"15:40
ubuntouristwilll send the results to a new file named "add_smallcaps.txt"15:40
ubuntouristThe END.  ;-)15:41
tboimahwow that was great15:41
tboimahThanks very much for today15:41
ubuntouristIt has been a very, very long story. ;-)15:41
tboimahyeah15:41
tboimahI understand a lot from it15:42
ubuntouristIf you can find time, sit with mulbah and  help him work through this. But make him do the work15:42
tboimahOkay15:42
ubuntouristthat we did today. He needs to type it and make mistakes like and figure out why things like15:43
ubuntouristwc -l egrep "qwert" README,md15:43
tboimahgot you15:43
ubuntouristdon't work right.15:43
ubuntouristor why an error message keeps saying "cur: no such command"15:44
ubuntouristSo much of systems administration (and programming) is trying to figure that stuff out.15:44
ubuntouristOK. We are WELL over time today. So, I need to run and do other things.15:44
ubuntouristBYE!15:44
tboimahThanks for today, and have a nice day.15:45
*** ubuntourist has quit (Quit: Leaving)15:45
*** tboimah has quit (Quit: Leaving)15:46
*** scooper has quit (Ping timeout: 480 seconds)19:49
*** sysadmin has quit (Ping timeout: 480 seconds)19:55
*** sysadmin_ has quit (Ping timeout: 480 seconds)19:57
*** janet has quit (None)20:02
*** sysadmin_ has quit (None)20:13
*** sysadmin__ has quit (None)20:14
*** scooper has quit (Ping timeout: 480 seconds)20:18
*** scooper has quit (Ping timeout: 480 seconds)20:37
shmohamudHi Scooper, you there?20:37
scooperHello Sahnun20:38
scooperDid you see my mail???20:38
shmohamudIs the commode a bathroom? Where did you drop your phone?20:38
scooperyes20:38
shmohamudYes I read it that's how I knew to show up now.20:38
scooperit was on change in the bathroom20:39
shmohamudI'm sorry about your phone, but it's a funny way to lose a phone :) lol 20:39
shmohamudWhen do you think you'll get a replacement?20:39
scooperNo I didn't lose the phone but water enter in the phone20:39
shmohamudOh, I thought you dropped it into the toilet20:40
scooperWhen the month end I will try to fix it20:41
shmohamudOk, the good news is you don't need a phone to learn javascript and meet with me :)20:41
shmohamudSo, shall we begin today's lesson?20:41
scooperhahaha yes20:41
scooperI m ready to tip up my programming knowledge 20:42
shmohamudExcellent. So as usual, some review of the previously covered topics20:42
scoopersure20:42
shmohamudCan you write me a function declaration that takes in a parameter of "name" and logs out "Hello {name}" Then call it with any name and let me know if it works.20:43
scoopersure20:43
scooper1Hello Sahnun20:52
scooper1are you still there20:52
shmohamudyes20:53
*** scooper has quit (Ping timeout: 480 seconds)20:54
shmohamudall good?20:55
scooper1yes20:55
*** sysadmin_ has quit (Ping timeout: 480 seconds)20:57
scooperdid you see the problem??20:57
scoopersolution?20:57
shmohamudno can you paste it again?20:57
scooperfunction greetingMessage(name){20:58
scooper    console.log("Hello " + name + "thanks for teaching me JS");20:58
scooper}20:58
scoopergreetingMessage("Sahnun");20:58
shmohamudWell done :) And I like the function name, it simply puts what's happening inside the function.20:59
shmohamudThe only change I would make would be to call it simply "greet" and call it as greet("Sahnun")20:59
scooperok21:00
shmohamudOk, so here's a new challenge with Arrow Functions. In an arrow function, you don't need to include a return statement if it's only one statement in the function body21:00
shmohamudIt will automatically return. If you have a multi-statement function, you have to explicitly include a return statement or else it will return undefined21:01
shmohamudAre you following me?21:01
shmohamudScooper, are you there?21:05
shmohamudScooper, are you there?21:07
sysadmin_yes21:07
shmohamudOk, did you read the bit about arrow functions?21:07
sysadmin_the question you just post in here??21:08
shmohamudLet me repaste it, it's about arrow functions21:08
shmohamudOk, so here's a new challenge with Arrow Functions. In an arrow function, you don't need to include a return statement if it's only one statement in the function body. 21:08
shmohamudIt will automatically return. If you have a multi-statement function, you have to explicitly include a return statement or else it will return undefined21:08
sysadmin_ok21:09
*** scooper has quit (Ping timeout: 480 seconds)21:09
shmohamudAre you following so far?21:09
scooperyes21:09
shmohamudso what does iAmAnArrowFunction = () => { 2+2 } return?21:10
shmohamudcompare that to iAmAlsoAnArrowFunction = () => 2+221:12
scooperthis is what the function will output if it call21:12
scooper() =>{2+2}21:12
shmohamudso here's a quick way to know what gets returned21:12
shmohamudIf there are curly braces in the arrow function, you must include a "return" statement or else it will return undefiend21:13
*** scooper1 has quit (Ping timeout: 480 seconds)21:13
shmohamudIf there are no curly braces and it's only a single statement, you don't need to include a "return" statement21:13
shmohamudStill with me?21:13
shmohamudU there scooper?21:16
scooper1yes21:16
scooper1I m here sorry my internet keep stripping21:16
shmohamudDid you see what I wrote about including the curly braces in an arrow function?21:17
scooper1yes21:17
scooper1but my thought for curly bracket is21:17
shmohamudOk, so what does iAmAnArrowFunction = () => { let sum = 2+2; console.log(sum) } return?21:18
scooper1I was thinking the curly bracket act as the indication for a code block21:18
shmohamudYes, they do for function declarations and *some* arrow functions.21:19
scooper1should I put it in the console or I should look I at and tell the answer21:19
shmohamudThere are some arrow functions that can be declared with curly brackets21:19
scooper1the output will be 421:20
shmohamudFirst, tell me based on the rules I explained, what would the result of iAmAnArrowFunction = () => { let sum = 2+2; console.log(sum) } return?21:20
*** scooper has quit (Ping timeout: 480 seconds)21:21
shmohamudOutput is not that same as the return value. What if I said testSum = iAmAnArrowFunction() 21:21
shmohamudwhat would testSum equal?21:21
scooper1if you store the function in a variable the out will be 4 when the variable is called21:22
shmohamudI want you to test it and let me know21:23
shmohamudcan you test it for me?21:23
scooper1ok21:23
shmohamudafter you set testSum equal to iAmAnArrowFunction I want you to console.log(testSum)21:25
scooper1something like this right ? iAmAnArrowFunction = () =>{21:27
scooper1    let sum = 2+2;21:27
scooper1    console.log(sum)21:27
scooper1}21:27
shmohamudyes, then set that equal to testSum and console.log(testSum)21:28
scooper1iAmAnArrowFunction = () =>{21:28
scooper1    let sum = 2+2;21:28
scooper1    console.log(sum)21:28
scooper1}21:28
scooper1testSum = iAmAnArrowFunction();21:28
scooper1the output is "4"21:29
shmohamudNow, console.log(testSum) and let me know what you see21:29
shmohamudwhat's the value of testSum, not what's getting logged to the console.21:29
scooper14 is the output but understand the 4 i m seeming "undefined"21:30
shmohamudExactly, it's undefined. Do you know why?21:30
scooper14 is the output but under the 4 i m seeming "underfined21:30
scooper1trying to figure out but seeming complicated21:31
scooper1please hold on21:32
scooper1let try21:32
shmohamudcan you try something for me? Instead of ending the function with "console.log(sum)" can you add "return sum"?21:32
scooper1sure21:32
shmohamudlet me know what testSum equals after you set it equal to that.21:32
shmohamudAlso I'm short on time, I have somewhere to be at 56pm and need to shower. After this we will continue tomorrow.21:33
scooper1ok21:33
scooper1iAmAnArrowFunction = () =>{21:33
scooper1    let sum = 2+2;21:33
scooper1    return sum;21:33
scooper1}21:33
scooper1testSum = iAmAnArrowFunction();21:33
scooper1421:33
shmohamudis the output undefined?21:33
scooper1no21:33
shmohamudit's 4 right?21:34
scooper1yes21:34
shmohamudThat's because we added a "return" statement. If you don't include the return statement in an arrow function with curly braces, it will return undefined by default21:34
shmohamudJust by console.log(sum) doesn't return anything, you must add the return statement or you will return undefined.21:35
shmohamudI know this is rather complex, but are you starting to see how return statements in functions work?21:35
scooper1yes I m seeming it21:35
scooper1but the problem here is that21:36
scooper1whether you use return or console21:36
shmohamudFor homework, I want you define two arrow functions. One of them should be one line and NOT include a return statement. Just have a value on the line like "Test Val" or "3" 21:36
scooper1the expression still display a output21:36
shmohamudThe second arrow function should include curly braces  (the first one should not have curly braces)21:37
shmohamudAnd it should include a return statement, return whatever you'd like as long as it returns.21:38
shmohamudconsole.log will always produce output whether you return it or not21:38
shmohamudI've got to run scooper but it's been a pleasure learning with you today. Looking forward to tomorrow. Try to knock out the homework or we'll do it together next class21:39
scooper1ok21:39
scooper1I will do it Sahnun thanks for the time21:39
scooper1see you tomorrow same time21:39
shmohamudsounds good, great job today.21:41
scooper1ACTION signing up for today21:41
*** scooper1 has quit (Quit: Leaving)21:42
*** shmohamud has quit (Remote host closed the connection)21:51
*** shmohamud has quit (Ping timeout: 480 seconds)22:10
*** shmohamud has quit (Ping timeout: 480 seconds)23:11

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