In the previous part — which you can find here — we were looking for solutions of quite simple task — printing isosceles triangle to console. In second part let us focus on a bit more complex problem — printing rectangular triangle with parametric angle. It may seem cryptic, so let examples speak:

Examples of triangles to print

Angle parameter may seem confusing in those examples. Don’t bother with that for now. We will focus on that later.

Divide & Conquer — again

It clearly is similar problem to one we solved in previous part. Those triangles are also built by smaller ones. …

There is really high chance that in some point in the past you have typed above phrase in Google or Stack Overflow search field. This problem is so common that it is the most voted question under javascript tag on Stack. If it is so popular why not have a closer look at that problem?

The problem of removing element from array seems ubiquitous and therefore important.

In JavaScript there are a lot of methods in Array itself, but also in other standard objects. Among those methods there are quite a few which can help us solve specified problem. It…

How to optimize Fibonacci sequence elements calculation in JavaScript

Fibonacci sequence in nature

TLDR: Implementing Fibonacci sequence is so common on programming interviews that it is worth to master this problem. Learn about simple optimization method of recursive implementation of this sequence.

Have you ever need to implement Fibonacci sequence calculating program as part of job interview? So many hands up! Let us investigate this simple problem. Shall we start with problem definition?

“Write a function which takes positive, integer number N as argument and returns N-th element of Fibonacci sequence. Use recursive definition of Fibonacci sequence.”

Mathematical definition of Fibonacci sequence looks like this:

fib(n) = fib(n-1) + fib(n-2)
fib(1) = fib (2)…

TLDR: Even as simple problem as printing triangle in console can have different interesting solutions. It is worth to tackle problems in systematic way and go from easiest to optimal to beautiful solutions.

Do you think printing triangle to console is easy and boring task? I will try to change your mind by going through meander of this problem. It is simple, extremely common task on junior developer interviews. There is also high chance that you will stumble upon it in Programming 101 courses of all kinds. Let us take a closer look at possible solutions.

We will define problem…

How I’ve got an interview invitation, how I prepared to the interview and how it went.

At the middle of February I was quite surprised when I’ve got a message on LinkedIn from Amazon recruiter. I was very excited and responded in a matter of minutes. Recruiter informed me that first step of recruitment process is technical screening. Then, I’ve got a link to the Codecademy-style platform and one week to complete two coding tasks.

Why recruiter contacted me via LinkedIn? I can’t be sure, but my guess is that she found me by Amazon Alexa keywords in my resume, as I was developing application for Alexa in the past. …

JavaScript provides Object methods which can restrict mutability of an object. The preventExtensions(), seal() and freeze() methods are great tools, although they do not exactly work as one might intuitively expect.

What is immutability and why is it desired?

A short answer to the first question is as follows:

An object is immutable when it cannot be changed (mutated).

But what exactly does “changed” mean? Does changing a newly created own property count? Yes, obviously. But does changing an inherited property in a prototype object count as “changed” in a child object? It’s not so obvious anymore. As you can see, things get complicated real quick.

Why do we even need immutability? There are several reasons:

  • Once created, the state of an immutable object doesn’t change
  • Better encapsulation. Passing an object to some method will not alter the original…

Maciej Twaróg

Programming computers is my hobby

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