Diff two arrays. When will I ever use it?

In Intermediate Algorithm Scripting there is an exercise Diff Two Arrays. Can anyone give me an example of using this script in the real life? I can’t imagine when I will ever use it.

Thanks!

Hello
Well, I think it could be interesting when trying to merge two datastructures (ex: two different customer or client databases ) in one without double. Or who are the most irregular or hesitating clients to whom you would like to entice more.

1 Like

More simply, let’s say you have a class, or a meetup group, or whatever. You have last month’s list and now this month’s and you want to know who added and who dropped. Or pick any list that might change.

In a DB, you might do it with SQL, but in a front-end UI you’re more likely to do it in JS. Anyway the idea of the challenges isn’t so much about real world code as it is to get you thinking in algorithms, so be prepared to see even more contrived problems down the road. Even those have a payoff as far as getting comfortable with data and manipulating it goes.

1 Like

Chuck, thanks a lot! Now it’s clear.
You know, front end dev is such a huge ocean. I’ve been working as a front end developer for three years now, but all I do is making layouts, working with Sass, svg’s and animations. This intermediate algorithm scripting is a black hole for me. That’s why my question.

What do you do? How come you know so much?

Thanks again!

Julia

@MrsColombo I’m in the same boat as you! I’ve been doing this awhile, pretty much the same Sass, svgs, BEM, some animations and such. Wanting to grow my freelance business and decided to give toptal a shot. Yep, humbling as hell! Couldn’t pass a single algorithm test, time to up my game by ALOT.

Hi Chadicus, I am glad to meet you as you are really in the same boat as me. I know now what my problem is. Couple of yaers ago, when I was learning front end for the first time I decided that I didn’t need vanilla JS. Why bother if there is jQuery and ‘all plugins are already written’!

And now I’m in the situation where I can make the most beautiful layout but if you ask me to do anything with logic in it, even to hide and show search bar on condition I’m speechless.

I’ve lost my job because of it. So I decided to get mad and get even with JS. Now I’m taking private lessons and making one execise a day.

What do you do?

After I was done kicking myself for not taking the time to learn and understand javascript, I’ve really dug into FCC, I now spend about half of the day (~4-6hrs ) practicing javascript (still need to eat and support a family, so even though I’d like to spend more time it’s just not possible right now). For practice it’s FCC, codeschool, pluralsight, codewars, and frontend masters. There is also a slack group with a bunch of FCC’ers (you can get more info here - https://tropicalchancer.github.io/projectus/ ).

As I said before, I’m a freelancer, so I didn’t need to worry about losing my job. While enterprise Sass & CSS architecture isn’t going anywhere I really saw if I want to stay relevant and take my freelance career to the next level I need to embrace javascript, not just the frameworks and libraries, but really develop an understanding of the language.

Chad

1 Like