Skip to content

Instantly share code, notes, and snippets.

View m1m6's full-sized avatar
🎯
Focusing

Mahmoud Jbour m1m6

🎯
Focusing
View GitHub Profile
@m1m6
m1m6 / flatArray.js
Last active April 21, 2019 04:59
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers
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]
@m1m6
m1m6 / filterAndGroupPeople.js
Last active April 20, 2019 18:18
Filter and group people by gender
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){