This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flatArray(arrayToBeFlatted, output) { | |
if (!arrayToBeFlatted){ | |
throw new Error('Please provide valid array') | |
} | |
if (!output) { | |
output = []; | |
} | |
for (let i = 0; i < arrayToBeFlatted.length; i++) { | |
const currentArrayItem = arrayToBeFlatted[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [{age:30, gender: "male", name: "john"}, | |
{age:31, gender: "male", name: "ahmad"}, | |
{age:32, gender: "female", name: "salem"}, | |
{age:39, gender: "female", name: "artugel"}, | |
{age:40, gender: "female", name: "micheal"}] | |
getResults(arr); | |
function getResults(arr){ | |
if (arr){ |