Imperative vs Declarative in JavaScript

Imperative code is telling the computer what to do in every step with details. Versus, Declarative code is what you want the results to be.

Let’s explain those concepts with examples.

Imperative Code

Below picture is an example for imperative code, there is a function called Filtered array and this function filters out the given array. What we…