Remove duplicate item from an array

Amena Akter
3 min readNov 6, 2020

Sometimes we see duplicate items in an array. For our work convenience it is very important to remove duplicate items. It is very simple to remove duplicate items from an array by using for loop. Let’s see an example:

Factorial recursive

Factorial recursive is a popular way for Multiplication integers. The factorial of x can be found by finding the factorial of a number one less than x, and then multiplying this answer with x. So the factorial of x-1 can be thought of as a subproblem that needs to be computed first. Let’s clear by an example:

Fibonacci Sequence

In this blog, I present two solutions for fibonacci sequence.

  • Iterative solutions
  • Recursive solutions

Let’s explain about these two items

Iterative Fibonacci:

At first I will solve the Fibonacci sequence using a for loop.

Recursive solutions:

Secondly I will solve the fibonacci sequence using recursive way.

Truthy vs Falsy

Truthy Value:

In javaScript, a truthy value is a value that is considered true.

Examples of truthy values in JavaScript :

  1. True,
  2. “false”
  3. “0”,
  4. “ ”,
  5. {},
  6. [],

Falsy Value:

In javaScript, a falsy value is a value that is considered false.

Examples of falsy values in JavaScript :

  1. false,
  2. 0,
  3. “”,
  4. undefined,
  5. null,
  6. NaN

Null vs Undefined

Null: There are two features of null.

  • null is an empty value.
  • null must be assigned.

Let’s see an example:

Undefined: undefined means a variable declared, but it has been assigned no value. If a function declare but it doesn’t return the parameters value it will also be undefined. Let’s see an example:

Double equal vs triple equal

Triple equal: In JavaScript triple equals === means testing for strict equality. This means both the type and the value have to be the same. Let’s see an example:

Double equal: In JavaScript double equals == means testing for loose equality. This means it checks the type not value . Let’s see an example:

filter an array object

In javaScript filter() method create a new array with all array elements passed for test. For filtering an array I create an array which has 3 properties- name, color, price.

To find the fruits whose price is greater than 200, I will run loop over the array elements using a map and test if the value of the price property satisfies the condition, like this:

--

--