Sorting Data Structures in JavaScript, Strings, and a little Node.js

A NOTE BEFORE THE SHOW.

I’ve made it a personal mission to counteract the modern-day scammer like “Tech Gurus.” Don’t buy into tech GURU mumbo Jumbo. Always fact-check me and everyone else who gives you advice. I’m no tech wizard, but Gurus are Perhaps the most unqualified educators out there. That being said, I want to talk to you about data “The Tech Interview.”

P.S

when I say Tech Guru, I really just mean people whose sole income is based on selling ideas like “anyone can program” or people who bank off selling personal lessons and just generally spilling out regurgitated trash that they learn from another tech guru who hardly coded at all too.

Love What You Do or Don’t Do It “PLEASE!!”

Love What You Do or Don’t Do it

The Tech interview is greatly misunderstood. Many Gurus Have no Idea what they are talking about when it comes to programming, and it can be challenging to distinguish Gurus from Honest, hard-working programmers just trying to make a little dough on the side. I catch myself wondering why any Developer would want to create a YouTube/Twitter/LinkedIn etc., why wouldn’t be coding more or learning more. When you think about the amount of effort it takes to gain an audience and how much time you spend marketing your brand and editing videos, how do you find the time to stay up to date. My thought is that they either.

  • I don’t actually like being a developer and don’t want to learn something else.

or

  • Those who can’t do teach, right? Isn’t that how the old saying goes. But I have a better conclusion. There is a whole Pyramid of half-baked developers who learn the bare minimum to teach code to people. Then they pawn off this Idea that you can learn code really quickly and live happily ever after, but that’s not true, sorry.

Something that has constantly been ringing in the back of my mind is the phrase “the pursuit of happiness.” That is what they are selling, but if you don’t enjoy the pursuit of what you do, you’ll never be happy. So please, to anyone trying to become a developer, and if you are learning off YouTube videos and literally counting the number of hours they spend coding, give it up. I love what I do. I mean “LOVE!” which is consistently disvalued in the industry because so many people become developers for all the wrong reasons. Don’t be a victim to gurus who lie about their understanding of code because once you reach their level, you’ll realize that Developing is an infinite paradox of learning. It won’t stop, and that is what being a developer means.

Talking Shop, “Code What You Know”

Okay, with my rant out of the way, let’s talk shop. If you’re serious about code, you have to build your own philosophy. When it comes to data structures and algorithms, mine is “don’t write what you don’t know.” What do I mean by that? Well, let’s look at an example. Let’s says you being interviewed for a role at a tech company, and they ask you to sort an array of strings alphabetically.

This is the array

So we can approach this from two angles, the first being an immaculate way.

Now This is an excellent way to sort an array in JavaScript and probably the most efficient. However, what if the interviewer was to asked how the sort method works. If you know how to explain and to write some pseudo-code, you’ll look pretty bad if you don’t. Why does this make you look bad? Because you “didn’t code what you know.” This only explained that you could remember a scenario and execute a procedure. By procedure, I mean “your memorized instructions to solve a problem.” Which is like the worst form of programming the exists. Developers don’t need good memorization.

Good Developers apply what they know to solve problems they don’t understand how to fix. You will never remember every solution to every situation. New challenges present themselves every day, and you won’t understand how to solve them every time. That’s why it’s good to “code what you know” because you’ll consistently be applying your “problem solving” skills rather than your ability to memorize “procedures.”

So what do you do if you don’t know how the .sort the method works. Apply what you know and if you don’t fully understand what I’m about to explain, go back to the basics and learn more. My advice is the “Rabbit Whole” method. Anytime you don’t understand something, research. If you don’t understand the research, research some more. If the topic is too complex, take it down a level; repeat that step until you make some progress.

If you have somewhat of an understanding of ASCII, this will make a lot more sense. However, if you don’t, ASCII is a character encoding that returns a numeric value that allows us to evaluate words like numbers.

Examples of Sorting When you Don’t Understand Built-in Methods

First:

Here is a list of random words from a method I concocted for a list of 433,551 words from a text file I downloaded as a zip then used nodeJS to create a giant array.

Then we need to create a function that, when given an array, will return an array order alphabetically. To be totally transparent, I actually copied this from StackOverflow though I did write my own code. I just liked this one more after getting mine to work.

Then We look at the result from sorting the with both the built-in function and custom function.

I’m not sure that these are even words, but here you have it.

To go back to “code what you know,” I’m not saying that you have to have a complete understanding of everything you do. However, you need to understand two tremendous things “what is the problem I’m solving” and “How do I know how to solve it.” In other words, even if you know there is a better way, if you’re not sure how something works, you should try writing using what you do know.

--

--

--

I love tackling new and exciting challenges and working with software because it’s consistently changing, which is exciting.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Building an XR Application in Unity with MRTK [Part 4] — Building the targets

Render Phoenix Error View inside Plug

React “Behind the scenes”

Setting up WSO2 sample OAuth applications with WSO2 Identity Server

What you may not know about the Error Boundary

Applying The React Architecture To Native Android, IOS & UWP Applications With React Native

Javascript: ES6 & Beyond

jQuery Is Better Than React

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
Cameron J. Leverett

Cameron J. Leverett

I love tackling new and exciting challenges and working with software because it’s consistently changing, which is exciting.

More from Medium

Postinstall Script Demo

How real-world web-based applications and software are built

Basic things to know about “Application Framework”

Objects from Module 3