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!