DEV Community

Cover image for  Day 16 of 100DaysOfCode
Arttu Pyykönen
Arttu Pyykönen

Posted on

Day 16 of 100DaysOfCode

Regex

Today I continued the regex challenges at FreeCodeCamp.

Regexes are weird little things. I have used them before when I worked with scrapers and they were confusing then and they are confusing still.

The idea of regexes is super simple and easy to understand, and the ones used in the FCC challenges weren't that difficult. But, when it comes time to actually use them they become a lot trickier. The real problem comes from figuring out the way to catch everything you want. And after you have figured it out you still have to write it using the cryptic characters.

They will probably become easier as time goes by, gotta just keep using them!

How to Regex

Eloquent JavaScript CH6

I also read some more Eloquent JavaScript. I'm on chapter 6 and it's all about Objects. One thing that felt cool was polymorphism.

This is how it's defined in the book:

"When a piece of code is written to work with objects that have a certain interface - like the toString method - any kind of object that happens to support this interface can be plugged into the code, and it will just work."

This means that we can change our object's pre-built methods to better suit our goals and still be able to use other functions that relied on the prebuilt version. That is cool.

Chapter 6 was a great read. You'll find links to the book below as well as the summary of CH6.

Twitter bot

I finished the Twitter bot that I started on day 12. I made it run on a PythonAnywhere server and it should reply to your mentions! Tweet @HappyTweetBot1 to have it like, retweet, and reply to you!

There were some problems last time when I decided to add a way to reply with a quote. It was solved when I moved the quotes to their own txt-file. Everything went pretty well and with a very small amount of bugs. Hopefully, it stays that way.

You can make your own version by following this tutorial by Code Wizard.

Study plan

As I said yesterday, I decided to make a more robust schedule for coding. My base plan right now is:

  1. Read a chapter of EJS in two days. Then do the exercises on the third day.
  2. Do at least ten challenges at FCC every day.

This is just the base plan and I'm adding some "spice" to the mix. The spice can be anything that I want to do on that particular day. I'll keep this at the beginning of my writings and change it as I see fit.

I encourage everyone to make a plan. Without one, I would be a lot like Kermit below.

Programming meme with Kermit. How I feel after ten lines of code

What I did today:

1. Worked on Regex challenges at FCC

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/

What I learned from it:

  • How JavaScript uses regex
  • Learned about literal match, wildcard char, and matching ranges or classes
  • Learned about different flags such as i, g

2. Read the rest of Chapter 6 of Eloquent JavaScript

https://eloquentjavascript.net/06_object.html

What I learned from it:

  • What is polymorphism
  • What are symbols
  • How iterable objects work (The book explains the behind the scenes)
  • Introduced to inheritance

3. Finished the Twitter bot

https://twitter.com/HappyTweetBot1

What I learned from it:

  • Debugging
  • Using a server to host my programs.

Time spent learning:

Task 'FCC'. Elapsed time: 0 h 30 min 15 s
Task 'Reading EJS'. Elapsed time: 0 h 49 min 48 s
Task 'Twitter_bot'. Elapsed time: 0 h 39 min 46 s

Time actually coding: 41 min

Total time: 1 h 49 min 49s

Time spent is tracked by my TaskTimer script and the WakaTime app.

Further reading

Summary, Eloquent Javascript CH6

"So objects do more than just hold their own properties. They have prototypes, which are other objects. They’ll act as if they have properties they don’t have as long as their prototype has that property. Simple objects have Object.prototype as their prototype.

Constructors, which are functions whose names usually start with a capital letter, can be used with the new operator to create new objects. The new object’s prototype will be the object found in the prototype property of the constructor. You can make good use of this by putting the properties that all values of a given type share into their prototype. There’s a class notation that provides a clear way to define a constructor and its prototype.

You can define getters and setters to secretly call methods every time an object’s property is accessed. Static methods are methods stored in a class’s constructor, rather than its prototype.

The instanceof operator can, given an object and a constructor, tell you whether that object is an instance of that constructor.

One useful thing to do with objects is to specify an interface for them and tell everybody that they are supposed to talk to your object only through that interface. The rest of the details that make up your object are now encapsulated, hidden behind the interface.

More than one type may implement the same interface. Code written to use an interface automatically knows how to work with any number of different objects that provide the interface. This is called polymorphism.

When implementing multiple classes that differ in only some details, it can be helpful to write the new classes as subclasses of an existing class, inheriting part of its behavior."

FreeCodeCamp

Check out FCC for the best interactive exercises! I have finished the Basic JavaScript and ES6 lessons and can recommend them for a beginner! You can read more about the Basic JS and ES6 challenges at posts "Day 8" and "Day 11".

Exercism coding challenges

Psst

You can check my answers to the exercises of Eloquent JavaScript. You'll find them here.

Have a great day and see you all tomorrow!

Top comments (0)