Author

Jwahir Sundai
5 Comments

Join Conversation
It takes as much energy to wish as it does to plan. — Eleanor Roosevelt

5 Articles

`Math.random()`

is an API in JavaScript. It is a function that gives you a random number. The number returned will be between 0 (inclusive, as in, it’s possible for an actual 0 to be returned) and 1 (exclusive, as in, it’s not possible for an actual 1 to be returned).

`Math.random(); // returns a random number lower than 1`

This is incredibly useful for gaming, animations, randomized data, generative art, random text generation, and more! It can be used for … Read article “Lots of Ways to Use Math.random() in JavaScript”

CSS has a special `calc()`

function for doing basic math. In this guide, let’s cover just about everything there is to know about this very useful function. … Read article “A Complete Guide to calc() in CSS”

There is a sentiment that leaving math calculations in your CSS is a good idea that I agree with. This is for math that you *could* calculate at authoring time, but specifically chose not to. For instance, if you needed a 7-column float-based grid (don’t ask), it’s cleaner and more intuitive:

```
.col {
/* groan */
width: 14.2857142857%;
/* oh, I get it */
width: calc(100% / 7);
}
```

You could probably prove that the `calc()`

takes the computer 0.0000001% … Read article “Keep Math in the CSS”

This is a full chapter excerpt from Wladston Viana Ferreira Filho's brand new book Computer Science Distilled which he has graciously allowed for us to publish here.

In almost every computation, a variety of arrangements for the processes is possible. It is essential to choose that arrangement which shall tend to minimize the time necessary for the calculation. —Ada Lovelace