Classes and Structs are very similar to one another. They both store data and model behavior.

Similarities

  • They both define properties to store values. Much like a key-value pair in Hash Maps.
  • They both have initializers to create instances with initial values. Objects can be created with initialized values to start with.
  • They can both conform to protocols. Some protocols are specific to classes, so only classes can conform to that specific protocol, but otherwise both can conform to it.
  • They can be extended via extensions for inheritance from other classes/structs.

Class Specific Capabilities

  • Classes can inherit other classes characteristics.

The Difference

The main difference…


For the record, I was not able to solve this LeetCode problem.

682. Baseball Game

You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds’ scores.

At the beginning of the game, you start with an empty record. You are given a list of strings ops, where ops[i] is the ith operation you must apply to the record and is one of the following:

  1. An integer x - Record a new score of x.
  2. "+" - Record a new score that is the…

This was something I had learned before, but was struggling to really memorize so I thought I’d blog about it.

I was just confused about when render would fire. As you can tell from the diagram, render fires before componentDidUpdate and componentDidMount.

Render also fires when passed new props or the state is set again. This diagram is pretty helpful for me to understand when render is fired, so I know what to put in there. forceUpdate is something I heard I should not use unless absolutely necessary, which is basically almost never.

That’s all for this week! Stay safe, maintain social distancing, wear a mask and wash your hands often!


JavaScript 30 is a 30 day challenge that pushes you to write code, perfect for beginners. I came upon this from my career coach, and found it super helpful. It teaches you how to write JavaScript and gives you a template to follow along with, along with a 1-to-1 solution of what’s in the video to follow along to. This is perfect for bootcamp grads who want to boost up their JavaScript.

This was just a quick post about this awesome resource!

Gear up, stay safe, you’re going back in! Stay safe everyone!


This drove me nuts! I could not for the life of me figure out why my components were rendering twice. Marios however summed it up pretty well.

He talks about why it renders twice, and the main reason is that React.StrictMode is trying to help you debug.

Rest assured, this only happens in development and doesn’t happen in production. Still, this bug drove me nuts for a while because I could not for the life of me figure out why everything was rendering twice!!! A real hair-puller for sure.

I highly recommend giving his blog a quick read because it…


Last week, I talked about how to add to an array in Redux. This week, to build upon and complement that, I’ll be talking about how to remove an item from an array. It’s not as easy as it may sound. It took me some Googling to find the answer to this question.

This is our initial state:

state={title: '',resultCt: 0,searchResults: {},nominations: []}

And we’re trying to change nominations . Given the nomination index in the array, this is how we would remove an item in nominations:

case 'REMOVE_NOMINATION':return {...state,nominations: [...state.nominations.slice(0…

Hey all! Another week for me as I complete a coding challenge sent by Shopify. This is my initial state:

state={title: '',resultCt: 0,searchResults: {},nominations: []}

Here, I want to add to nominations which is initiated as an empty array.

I tried state.nominations.push(action.nominations) which was my first thought that came to mind, but that didn’t work. Instead, I have to do the following:

case 'STORE_NOMINATION':return {...state,nominations: [...state.nominations, action.nominations]}

I have to spread the state first with ...state and then I have to set nominations to a new array, spreading the original state…


This week is just a rundown on a Leetcode problem I went through.

Here’s the solution:

/**
* @param {string} J
* @param {string} S
* @return {number}
*/
var numJewelsInStones = function(J, S) {
let jewels = J.split("");
let stones = S.split("");
let ans = 0;

for(let i = 0; i < jewels.length; i++){
for(let j = 0; j < stones.length; j++){
// if (jewels[i] ===…

I found out recently that you can have a featured section in your Github.

https://www.aboutmonica.com/blog/how-to-create-a-github-profile-readme

For example, from Monica:

To do this, it’s pretty simple. Just make a repository and make sure you name it exactly as your Github username, case sensitive. Github will tell you that this is a secret repository just for you!

They’ll even give you some recommendations to start you off on the right foot.

Here’s mine for reference:

Remember that a Readme is in .md, or markdown format, meaning you can put GIFs in there as well as emojis.

That is all folks! Have a good one and see you all next time! Stay safe, take care, we’re going back in!


I had my first code challenge in a while from Codecademy. I’m pretty excited about this opportunity. I quickly opened the email from Codecademy, anticipating the chance to get to write some valuable code. They said that the code challenge should take a recommended 2–3 hours. Little did I know… I’d be spending about an entire week on it. Good thing I started early though.

I definitely was stressed out during parts of it. Overall though, I had quite a bit of fun. We just had to make a quiz using data that they prepared for us.

This was…

Lawson Hung

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store