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
const traverse = (arr, parentId) => | |
arr.filter(node => node.parentId === parentId) | |
.reduce((result, current) => [ | |
...result, | |
{ | |
...current, | |
children: traverse(arr, current.id) | |
} | |
], []) |
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
const developers = [ | |
{ | |
id: 1, | |
name: 'John Doe', | |
age: 29, | |
sex: 'male', | |
level: 'senior', | |
earnings: [ | |
{ | |
month: 'February', |
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
/* eslint-disable */ | |
/** | |
Based on https://github.com/ka-weihe/fastest-levenshtein | |
MIT License | |
Copyright (c) 2020 Kasper Unn Weihe | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |
and associated documentation files (the "Software"), to deal in the Software without restriction, | |
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, |
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
// Required imports | |
export class ContactsTab1Page implements OnInit { | |
contacts$: Observable<Contact[]>; | |
} | |
// Constructor | |
// Executed each time the tab is activated | |
ionViewWillEnter(){ |
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
/** | |
* Returns the sequences of repeated subsequence chars | |
* Example 1: 'Niiiiiiiceee' will return ['iiiiiii', 'eee'] | |
* Example 2: 'NiiiiiiiceeeNiccceeeeeeeeeee' will return ['iiiiiii', 'ccc', 'eeeeeeeeeee'] | |
* | |
* Notice that in 'Example 2', the 'e'char sequence that is returned is the second one, because it's bigger than the first one. | |
*/ | |
const singleSequencesEqualChars = function(word) { | |
let counter, |
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
// Standalone Collatz Conjecture function (https://en.wikipedia.org/wiki/Collatz_conjecture) | |
const collatz = (input) => { | |
let result = []; | |
let value = input; | |
while(value != 1) { | |
value = (value % 2 === 0) ? value / 2 : value * 3 + 1; | |
result.push(value) | |
} |