This file contains hidden or 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 n = 5 | |
| for (let i = 1; i <= n; i++){ | |
| for(let j = 1; j <= n - i; j++){ | |
| process.stdout.write(' ') | |
| } | |
| for(let k = 0; k < 2 * i - 1; k++){ | |
| process.stdout.write('*') | |
| } | |
| console.log() |
This file contains hidden or 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
| /* REGEXes */ | |
| const REGEX_INT = /^-?\d+$/; | |
| const REGEX_EMAIL = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/g; | |
| const REGEX_PASSWORD = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/gm; | |
| const REGEX_IPv4 = /\b(?:(?:2(?:[0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9])\.){3}(?:(?:2([0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9]))\b/ig; | |
| const REGEX_IPv6 = /(([a-fA-F0-9]{1,4}|):){1,7}([a-fA-F0-9]{1,4}|:)/gm; |
This file contains hidden or 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 permissions = { | |
| Admin: ['/', '/users'], | |
| undefined: ['/login'], | |
| null: ['/login'], | |
| }; | |
| const initialState = { | |
| status: false, | |
| }; |
This file contains hidden or 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 concatArrays (firstArr, secondArr) { | |
| return [...firstArr, ...secondArr] | |
| } | |
| concatArrays ([1,2,3], ["Hello world!", "Mondongo"]) | |
| // [ 1, 2, 3, 'Hello world!', 'Mondongo' ] |
This file contains hidden or 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 countDuplicate = (array) => { | |
| let object = array.reduce((prev, cur) => ((prev[cur] = prev[cur] + 1 || 1), prev), {}) | |
| console.log(object); | |
| } | |
| countDuplicate(['test', 'test', 'test2']) |
This file contains hidden or 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
| let result = [] | |
| const REGEX_INT = /^-?\d+$/; | |
| const isNumber = (value) => { | |
| return REGEX_INT.test(value); | |
| } | |
| const fakeBinary = (param) => { | |
| if (isNumber(param)){ |
This file contains hidden or 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
| export const everyWeek = (x) => { | |
| let prev = new Date(); | |
| prev.setDate(prev.getDate() + (x+(7+prev.getDay())) % 7); | |
| return prev | |
| .toISOString() | |
| .slice(0, 10) | |
| .replace('T',' '); | |
| } |