Tuesday, June 25, 2019

Day 079: Accessing Objects with Variables

Still working through the FCC Javascript Algorithms And Data Structures section and I am going through them pretty quickly thanks to all the practice I got on Codewars and Edabit as well as Angela Yu's Bootcamp (which I still haven't finished by the way. Currently at 90% done... need to finish soon!). I am hoping to get the certification for this section sooner rather than later. No specific date, other than "soon". Whenever I list a date, I seem to jinx it where something shitty occurs and derails me for a bit.

But I digress. So I also managed to finish two of the projects for the certification, the Palindrome Checker and the Telephone Number Validator (Regex). I think they are the two easier projects (and I actually enjoyed regex?) so I expect to spend a bit more time working through the other ones. I already looked ahead and they seem pretty difficult!

Anyways, I just want to plop the bit below as a reminder to myself on how to access through the keys of an object, in the below example is by using the For In loop (which I need more practice with).


let users = {
  Alan: {
    age: 27,
    online: false
  },
  Jeff: {
    age: 32,
    online: true
  },
  Sarah: {
    age: 48,
    online: false
  },
  Ryan: {
    age: 19,
    online: true
  }
};

function countOnline(obj) {
  // change code below this line
  let count = 0;
  for (let user in obj) {
    console.log(obj[user]["online"])
    if (obj[user].online === true){
    count++;
    }
  }
  return count; 
  // change code above this line
}

console.log(countOnline(users));

I got really tripped up with this one. Just a note to myself that I need to use brackets when accessing the key values with a variable!

obj[user]["online"]   or   obj[user].online

It was something I was banging my head over for about 30 mins. /bleh

Oh yeah, I changed the blog subdomain from anncc.blogspot.com to anncodes.blogspot.com. Not sure why I didn't think of that to begin with..


Sunday, June 23, 2019

Day 077: Finally Out of the Slump? Coding/Algorithm Challenges

As I eluded to in my tweet, I was still feeling some sort of way after the theft and invasion of privacy so much so that it affected me a lot more than I care to admit. It still really bothers me even now.


Like I really couldn't bring myself to do anything productive and only squeaked by with "coding" by watching (and sometimes coding along) with videos CSS, NodeJS and such. But thankfully a member from my Daily Accountability group suggested doing Codewars problems together which really helped get me out of the slump.

I really enjoyed it when I did the Lighthouse Labs 30 day challenge. But now that I am kind of having a go at it myself, I am finding the challenges on these types of sites really addicting. And I get to learn more about JS and practice to boot!

So far, I've signed up for:

I think I will stick with those 3 for now. 3 is even probably a bit much right now.

I like the Codewars set up the most, though it can get really slow at times. Edabit is a close second and is much faster. Hackerrank can be confusing at times with their instructions and set up (or maybe it's the issues with the particular set of challenges I've encountered), but so far so good. What is great about all of them is that they display other user solutions after you complete your own which also has been a great learning experience to see how more experienced folks do it. This sometimes leads me down a rabbit hole of learning about different methods and getting more exposure to them.

FreeCodeCamp Challenges

Even better was finding out that FCC had challenges in their JS Algorithms & Data Structures section. I mean, I probably peeked ahead at them when I started FCC way back when and thought to myself that it all looks like gibberish and that it will make sense to me in time... well, now's the time! I guess I want to save some of my answers that I was particularly pleased with.

Basic Algorithm Scripting: Return Largest Numbers in Arrays
Probably not the most efficient code in the world, but I was pretty happy with solving this one. It is close to the basic solution they presented.
function largestOfFour(arr) {
let answer = [];
  for (let i = 0 ; i < 4 ; i++) {
    let maxNum = arr[i][0];
    for (let j = 0 ; j < 4; j++){
      if (arr[i][j] > maxNum) {
        maxNum = arr[i][j];
      }
    }
    answer.push(maxNum);
  }
  console.log(answer);
return answer;
}


Basic Algorithm Scripting: Title Case a Sentence 
I solved a similar one to this particular challenge in Codewars (or was it Edabit?), but it was done with the basics length and iterating through the array with a for loop. I needed some practice with using map() and came up with the below. It's a bit of "code golf" (for me at least). I also got some use out of substring() as well!
function titleCase(str) {
  let arr = [];
  str.toLowerCase().split(" ").map(x => arr.push(x[0].toUpperCase() + x.substring(1)));
  return arr.join(" ");
}

titleCase("I'm a little tea pot");


Basic Algorithm Scripting: Chunky Monkey
Only because I wanted to get more practice out of a while loop, I came up with the following answer which is similar-ish to one of their advanced solutions. I also ended up using slice() and originally attempted to push it into an array assuming that it removes the items from the array, but slice doesn't work that way. After peeking at the rest of the solutions, what I wanted to use was splice() which does actually remove the elements from the array.
function chunkArrayInGroups(arr, size) {
  let answer = [];
  let add = 0;
 while (answer.length < arr.length/size) { 
     answer.push(arr.slice(0+add,size+add))
     add = add + size;
    }
  console.log(answer)
  return answer;
}


Basic Algorithm Scripting: Mutations
A tiny bit more code golfing.
function mutation(arr) {
  for (let i = 0 ; i < arr[1].length ; i++){
    if (arr[0].toLowerCase().indexOf(arr[1].toLowerCase()[i]) < 0) {
      return false;
    }
  }
  return true;
}


JavaScript Algorithms and Data Structures Projects: Telephone Number Validator
This one was a doozy. I was initially very scared of regular expressions, but after going through the RegEx section in the FCC, it's not so bad! Especially when you have a handy tool like Regex101 with you.

FCC's regex /^(1\s?)?(\(\d{3}\)|\d{3})[\s\-]?\d{3}[\s\-]?\d{4}$/ 
MY regex /^1?\-?\s?(\(\d{3}\)|\d{3})\-?\s?\d{3}\s?\-?\d{4}$/ 

I was surprised at how close I came to their basic solutions. My answers aren't a perfect match but it still works. That's what I love about programming.. there's more than one right answer!


Sunday, June 16, 2019

Day 070: In a Slump - Phone Stolen

So the day after the last post, my phone was stolen when I was at the grocery store. It was a first generation Pixel that was due to be replaced anyways so in terms of actual cost, at most I lost the $50 or so trade in value for the phone.

Originally the phone was connected to a case in which my car keys (with the keyless fob) was attached to, along with my IDs, and credit cards. I do not carry cash. Initially, with the car keys alone being gone, it could have been about $700 to reprogram and replace (which is freaking ridiculous, btw). As well as paying to replace the word ID and drivers license which would have cost $25 per ID. Cancelling the credit cards were easy enough. And $400 to replace the cell phone, which I was delaying another year since I was saving up for a vacation and the Pixel still worked just fine. There was also the worry that since my IDs had my address on it, the thieves would know where I live and had my house keys so the locks would need to be replaced.

Unfortunately, the store cameras were not facing the aisle my cart was in, so they were not able to confirm who took it. I also reported it to the police, but that didn't do much either. But I suppose the silver lining was that 2 hours later, everything else was returned with the exception of phone being ripped out of the case. I am still going to change my locks as a precaution.

Oh yeah, the feeling after realizing it was gone was one of panic and vulnerability. And the fact that I did not even know anyone's phone number to even call for help was even worse! The only number I knew was literally my own phone number! The grocery store was a 30 minute walk from home and that's what I had to do. It was not a good walk home.

The likeliest culprit was probably a pair of teens hovering around me before it was stolen since it was about 1 min between checking my phone and finding it missing. At least that is my hope because that phone connected to a whole lot of accounts: emails, work, medical, retirement and I am hoping that teenagers are less nefarious in terms of trying to break in and get my personal information. No, I am not the type of person to take compromising photos of myself or anyone (that's just stupid) so at least I don't have to worry about that. Everything was password protected and changing the login credentials would just about block everything out. I am not sure if I set it up so that the memory is wiped after multiple failed attempts of logging into the phone. I did try the Find My Device tool from Google and the phone never reconnected with the network after it was stolen. My hope is that if I did not set it so that the memory is wiped after X failed attempts, that they just did a reset and wiped everything.

There were lots of accounts I had 2 factor authentication to which essentially blocks out many of my accounts until the new phone arrived and the suspended number reactivated.

So I basically spent about 8 hours following the theft on the computer changing passwords and on the phone with various companies in regards to proving my identity to reset the 2 factor authentication. Then I spent the next few days worrying and dealing with follow up issues of not being able to access accounts (including my work accounts, since they require 2FA to access the network).

Not to mention finally getting my new phone, the Pixel 3a and then spending 3 hours in Verizon last Friday trying to get it reconnected to the network so I can get my phone number back and finally re-access some of the 2FA that required my phone number. /Sigh

The theft happened on a Saturday afternoon. That was the weekend I was feeling pretty damn good about the highs previously and was planning on doing another Personal Mini Bootcamp on Saturday and Sunday. The best possible outcome in terms of least $$ associated of having my car keys returned happened. But even a week later, I still feel like shit about it all and just thinking very poorly of humanity in general. Seriously, who the fuck does that? And there's basically nothing I can do about it either.. nothing!

I've basically been derailed since then and had been trying to make myself feel better and not worry about the what ifs. It has been a lot less productive in learning to code and I have been feeling pretty demotivated. Compare the previous week of 22 hours of very focused coding and learning to barely getting to 10 hours in. And that is only because I had to make myself watch some videos on foundational JS or CSS to at least keep it in my mind, not that I was actively coding or anything. It's been a week and I am not sure how to get myself motivated again. Ugh.

I was attempting to do another mini bootcamp at least one 8hr day of coding this weekend and not just watching videos. But I find myself procrastinating by cleaning the house or other menial chores, playing video games, or even using my family as an excuse to stay away from the computer and generally keeping my mind off things.

I know I need to give myself the permission to do what I need to do to feel better, but the fact that I am cognizant of how much the theft and invasion of privacy is affecting me makes me upset even more. /Sigh

I'll do what I have to do and hopefully my next post is back to normal.


Friday, June 7, 2019

Day 061: Networking and Support Wins

Hey! It's been one day over two months since I started learning to code! Woo!

I'm still going through Angela Yu's Web Dev bootcamp (getting close to the finish line!). I've only finished a few small independent projects along the way and hope to get much more under my belt in the coming days. I didn't finish the FCC JS certification yet since I was interrupted with the busy season at work and I took a detour into the wonderful world of Udemy. I do intend to get that FCC JS certification eventually!

In the meantime, I want to report a few significant wins this week. Before I start, let me preface it with the fact that I am an introvert and I HATE having to go to networking events. I would rather get my teeth pulled than to have to small talk myself though these types of things. It is just so uncomfortable for me, I am figuratively dying inside. However, I've worked in front-desk type positions before and overall have been working long enough generally that I can fake it through the whole thing so that people around me don't get so uncomfortable with me being so awkward and in pain (or maybe they do notice? That would explain the cautious backing away, lol).

Monday: The Approach 

So I am part of a leadership program at work. It's a small internal program that consists of workshop and presentations. My cohort was having our graduation ceremony of sorts this past Monday. Let's just say I would not have joined this program if my boss didn't strongly urge me to do it. It is a pretty good program and a convenient excuse to get to know other folks at my workplace (and I actually made a friend out of it). But if I had a choice not to participate (without looking bad to the higher ups), I would have chosen to stay away from it.

So "graduation" rolls around and I was delighted to find that the guest speaker was a CEO of a machine learning company in the city! Yes, one of the few female CEOs of a tech company! Wowowowowwo! Her speech was short but inspiring and I was sitting on the edge of my seat drinking in everything she said!

Before she even finished, I already decided that I will approach her and began formulating how I was to do that, since I NEVER do anything like this. I wondered how my extroverted, salesy friends would do it? Even so, I didn't think too hard about it, because I approached her after right away and told her how inspiring her story was (and it was!). I also told her that I was currently learning to code and am hoping for a career transition. I was sweating bullets the whole time and my heart was racing and was trying really hard to not be awkward and weird.

Imagine my surprise to see that she was so excited for me and was even saying how she has some positions opened in her company (where I had to meekly inform her that I was not quite at that level yet). She offered to connect on Linkedin and later have coffee...!! Ahhhhhhhhhhhhhh!!

If you told me 3 months ago that I would have done something like this, I would have laughed in your face. I still can't believe that I did this. It was way out of my comfort zone, but so worth it.

Wednesday: The Science Fair

The second event was another internal event for career development/connections. I didn't actually plan on going to this but was walking by a sign they had with a greeter standing by. I mentioned to myself "oh yeah, this is going on." The greeter heard me and said, "You should go!" So I thought why the heck not? And off I went.

It was sort of set up like a science fair how each department had their own table. My org is big enough that each major department (or channel?) has their own HR, admin, marketing, IT, development teams as well as organization-wide teams that oversee the overall mission of the organization.

At the event, I found some friends and chatted with them a bit. After everyone took their leave, I kind of poked around to look for the organizational wide IT/tech dept. There was only one person manning their table and someone else was talking to them. I loitered around a bit looking at their job postings, none of which I was qualified for and waited for my turn to chat. There were a few times I was tempted to just walk away because I felt awkward and uncomfortable, but I am glad I did not. Eventually, I had my turn and awkwardly fumbled out my words (so awkward!) and told the woman I was learning to program and am looking for a career transition. But once I began talking, I could not believe how excited I was to talk to her and I could not shut up.

She was an HR person who works for the tech dept, but still was so happy for me to be a woman actually interested in tech. As I was yapping on, there was another woman who approached and was awkwardly waiting for her turn to talk to the tech dept and I just randomly asked what programming languages she knows. My husband tells me later that this was kind of a silly question and should have asked her what stack she was working with instead. Hey, I am new at this! It was kind of evidenced in her face with the confused look she gave me (haha!). But she explained that she was in devOps for one of the smaller departments. However! Since she was already in the know, she referred me to a bunch of internal organization wide resources that I had no idea even existed! An especially important group is a women in tech group! Yassss!

Friday: Lunch Time

awesome support from a friend + delicious udon for lunch = WIN!
And just today at lunch, I had lunch with my friend in HR at a delicious Udon spot she introduced me to.

I finally told her about my plans on learning to code and pivoting to a different career in a year.

Since she works in HR, I was a bit shy in letting her know. I knew each other before I started working at the same place and have become better friends since I started working here. However, I was unsure of how she'd feel/react because she is in HR after all. This news can potentially can affect her work. I also had a fear of her telling my boss before I was ready (which she would never do, honestly, but the fears there).

But you should know the theme of the post by now. She was absolutely SUPPORTIVE of me and my decision. She was going so far as offering to help connect me to folks she knew in our IT/tech department. I was planning on approaching them anyways, but getting an intro would be even better!

Too Long Didn't Read

I am getting way out of my comfort zone reaching out to people and realizing how it does NOT feel uncomfortable when it is about something I am passionate and care deeply about.

Just is put yourself out there! You will be shocked at how people just want to help and see you succeed! You might even surprise yourself as well.

I am just bursting with so much optimism and motivation right now!

Wednesday, May 29, 2019

Day 053: BTDT Tip Calculator & Bill Splitter - using parseFloat, toFixed & building it in order to make it work!

Yesterday, I took take a short break from the bootcamp for a day to let the information sink in a bit (see active and diffuse learning). So what better time than to do my next BUILD THE DAMN THING project. It is a handy tip calculator & bill splitter that I probably spent way more time on that I should have.

See the Pen Tip Calculator/Bill Splitter by 4nn (@4nn) on CodePen.

Some Things I Learned

I guess I already knew these things, but it was more so putting it into practice and getting to experience the joys of parsing strings to numbers to strings to numbers so the formula would work.

I initially thought this would be quick and easy since I banged out the formula in the console in less than 5 mins.

parseInt(), parseFloat(), .toFixed()

Of course the console just deals with the parameters as numbers. It is a different story when you are pulling values from the DOM, which would output those numbers into a string. You can't really do math with strings!

So I became intimately familiar with the parse functions to get those strings into numbers. (Good to know when I tackle the building a calculator project)

parseInt() parses the value into an integer. I used this in the beginning since I was testing with whole numbers.
parseFloat() parses the value into the floating point number (with all the decimals and such).

Once that was all set, I later used the .toFixed() method to get the numbers into 2 decimal places.

Voila! The math actually worked with the DOM in codepen!

So I go about to add in the conditionals and error messages and such, but the conditionals did not work because it was essentially asking if the preTipBill === NaN. Why did it keep coming up as NaN even though the math worked out previously? Enter frustrationland!

My husband probably noticed my annoyance after some time which was his cue to help (of which I didn't ask for his help, but recognize that I need to get better at knowing when to ask). So he identified that I was doing too many things at a time before calling the if statement. I was assigning the DOM values to the variable and then reassigning the variables to parseFloat().toFixed() and then setting the condition statement. It looked something like this:

 let preTipBill = document.getElementById("preTipBill").value;
 preTipBill = parseFloat(preTipBill).toFixed(2);
 let tipPercent = document.getElementById("tipPercent").value;
 let splitBetween = document.getElementById("splitBetween").value;
 splitBetween = parseFloat(splitBetween).toFixed(0);

 if (preTipBill === "" || tipPercent === "" || preTipBill.length === 0 || tipPercent.length === 0) {
  ...
 }

Of course that mess was then checking the if conditionals to preTipBill === NaN which is not what I want especially when trying to reassign blank splitBetween values to 1 if the user opts not to split the bill. Anyways, once he pointed that out, I got it right away. Like, RIGHT AWAY. Rookie mistake!

  let preTipBill = document.getElementById("preTipBill").value;
  let tipPercent = document.getElementById("tipPercent").value;
  let splitBetween = document.getElementById("splitBetween").value;

  if (preTipBill === "" || tipPercent === "" || preTipBill.length === 0 || tipPercent.length === 0) {
    document.getElementById("output").innerHTML = "Please input all required amounts!";
  } else {

    preTipBill = parseFloat(preTipBill).toFixed(2);
    splitBetween = parseFloat(splitBetween).toFixed(0);

I needed to reassign the values LATER, preferably once the condition is met. Just moving the reassignments fixed the whole thing. Sheesh!

In working through all the projects in the Angela Yu Web Dev Bootcamp, the location of the reassignments were sort of laid out for you when working through the projects and it made a ton of sense at the time, of course. But it really isn't until you've been frustrated and 😬 over it for an hour that it really sinks in. The ORDER of your code matters! I found this to be a very valuable lesson.

On a side note: it's my mom's birthday this Saturday and I'll definitely be pulling out this little calculator at the end of the meal!

Here's the User Story
  • user inputs total initial bill
  • user inputs desired tip amount
  • user gets error message if initial bill and tip amounts are missing
  • display the tip subtotal
  • display the total amount
  • user can opt to split the bill, input number of people to split it with
  • display the per person initial bill
  • display the per person tip and total
  • if user does not split bill, only display the tip & final total
  • have button calculate and clear all

Tuesday, May 28, 2019

Day 052: Personal Bootcamp Debrief

So it's Tuesday now and the long weekend has come and gone. How did my personal bootcamp go?

It was really tiring, but a GREAT experience. I didn't want to spend too much time blogging about it while it was going one since I wanted to dedicate most of the time during the weekend to coding and learning to code. I posted some thoughts on instagram during the weekend.

Day 1:

Day 3:

The plan is to do something like this once a month and maybe drag some folks from my accountability group into it as well, if they want to jump in for a day or so.

As for how far I got through the material (Angela Yu's Web Dev Bootcamp), I was at 23% of the course having just finished the Bootstrap section when I started the weekend. I ended the weekend at completing 66% of the course and am into the first few videos on JSON and API.

Sort of Daily Breakdown

I was mentally wiped out the first day since it was pretty much a continuous 8+ hours of learning and coding.

The second day was much better because I took a long break in the middle so it was like 2 medium sized coding sessions vs one big long one on the first day. It was also mostly working on a project that day (building a Simon Says game) so that added variety. I also kind of stayed up until 2am in the morning that evening watching more of the videos after finishing the project because I felt like I was on a roll.

The last day was a bit shorter (since I got in those hours in the AM ), so it was not bad in terms of total hours required for the daytime. I did do the minimum number of hours on the last day so I can enjoy the long weekend and let my brain rest for a little. In all, I did clock in bout 25.5 hours of learning and coding in the past 3 days.

What I Learned

I feel like I learned SO much! The three big things: being more comfortable with the DOM, being introduced to NodeJS, and finally learning the CLI/Git/Version Control. The next bits would be to get through the API section (which is also very cool!), moving on to databases, RESTful API, and authentication and security. I would like to finish the course by the end of this coming weekend, but we will see how that goes since it depends on how much time it takes to get through the projects.

Hi NodeJS. I am so excited to meet you!
I must say, I really enjoyed the projects in this bootcamp. When she introduces you to a concept, there is a bit of code-along happening. Then there's the pausing before each mini challenge so you can work through the concepts on your own before you unpause and she goes over it. For the big projects (what she calls "boss level challenges), she lays down the to-do's for each step and you tackle them one by one. At the end, she goes over the whole project. I opted to not review her solutions unless I feel really stuck (and am happy, but annoyed with myself to say that I peeked only once during the Simon Says challenge).

You know I already had that problem before where the initial look at the code makes me wonder how in the world I can ever get to that point. But those step-by-step to-do requests really help remind me that this is what programming is all about. They are all little steps to get to the final product. And when your app works and you look back at the code, everything actually makes sense!

What's Next? 

I know I haven't finished Angela's course yet, but I am already looking ahead. Here are my next to-do's:
I added another intro-to style course to the list, Andrei Neagoie's ZTM because he has sections that cover React & Redux which I feel is something important that is missing from Angela's course. His projects also seem really interesting too. Colt Steele's Web Dev Bootcamp course also ranked high, but he is missing React & Redux so I did not really consider it. I might consider Colt's Modern React Bootcamp course in the future though.

For Andrei's ZTM course, I will skip the parts that I am comfortable with (HTML, CSS, JS basics), use the parts I am not yet comfortable with as review on 2x speed, and delve into the projects for the experience. I am also interested in his more intermediate course, the Complete Junior to Senior Web Developer Roadmap (2019) and figured I ought to see if I like his teaching style before jumping into another 30+ hour course. Use the coupon code LEVELUPZTM to buy his course fo $10.99 without having to wait for a sale.

The focus of the list is projects, projects, PROJECTS! Which is why Wes Bos' JS30 is on the list as well as the Odin Project. I was actually slowly going through TOP Web Dev 101 as bedtime reading, so I am about 33% done with it already. It follows along nicely with Angela Yu's bootcamp contents this past weekend. In TOP, I am skipping the parts related to Ruby or Rails, but might revisit that in the future. TOP just seems to have some really great projects and the curriculum is constantly being updated (contrary to what they say on the internets).

In the middle of all this, I do intend to do the challenges and projects on FCC as well. I would like to get the full stack FCC certification eventually! FCC is kind of where it all started, so of course it is always on the list. I do admit that the website alone was not enough for me to understand the material (sometimes the wording of the challenges confused me) hence my branching out to Codecademy, Lynda, and Udemy which has been working well in helping me learn.

Okay, this post was a lot longer than intended, but it is really good to create a roadmap for myself to tackle in the next few months. This also helps to know what I am doing for my next Personal Bootcamp!


Saturday, May 25, 2019

Day 048: Personal Bootcamp Weekend

Memorial Day is on Monday. So you know what that means? A long weekend!

I wanted to quickly post that I am currently attempting a self imposed bootcamp over the next 3 days. The goal is to get in at least 8 hours of learning and coding each day as if I was attending a real bootcamp.

Of course I want to move along with my learning and ability and one of the obvious reasons why bootcamps work for some people in a short amount of time is due to the sheer number of hours they spend working on the material. I want to create a similar experience for myself (sadly, by myself for now) at a much lower cost. Hopefully, this is something I can do for most weekends and all upcoming long weekends (if the day job permits).

To facilitate this first Personal Bootcamp Weekend, I am using the Complete Web Development Bootcamp w/ Angela Yu (of note that there is a Memorial Day sale going on right now for $11.99; if you don't see a sale price on Udemy, just wait a few days for some kind of holiday. They always have sales). I finished up until the Bootstrap section last night and am starting my long weekend bootcamp right at the JS section. That works for me!

My favorite person right now!
The plan is to try to go as far as possible starting at JS in the next few days. Other tasks will be finishing up the Intro to JS @ codecademy and working on my tip calculator/bill splitter and the day counter app. If I can fit it in, I will also be building a Tabata timer as well. I will also probably use a KhanAcademy course as a break from the intensity occasionally.

Let's ROCK this!