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
| // DEBUG | |
| // Printing objects on console | |
| const foo = {name: 'tom', age: 30}; | |
| const bar = {name: 'harry', age: 50}; | |
| const baz = {name: 'john', age: 19}; | |
| console.log({ foo, bar, baz }) // To show objects names on console. | |
| // Styling with css | |
| console.logo('%c My friends', 'color: orange; font-weight: bold'); | |
| // Console table |
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 onChange(control, oldValue, newValue, isLoading) { | |
| if (isLoading || newValue == '' || newValue == 'false') { | |
| return; | |
| } | |
| var multiRowSysId = 'sys_id'; | |
| var checkBoxField = 'os_horarios_forao_totalmente_preenchidos'; | |
| // Mensagem de erro |
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
| console.time('test'); | |
| const saldosQtd = [ | |
| { | |
| qtd: 1 | |
| }, | |
| { | |
| qtd: 10 | |
| } | |
| ]; |
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
| // Without Reduce | |
| function simpleArraySum(ar) { | |
| let total = 0; | |
| for(let elem in ar) { | |
| total += ar[elem] | |
| } | |
| return total; | |
| } | |
| // With Reduce |
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 stockAndCount(n, arr) { | |
| let pairs = 0; // pairs number | |
| const colors = arr.reduce((acc, val) => { | |
| acc[val] ? (acc[val] += 1) : (acc[val] = 1); | |
| return acc; | |
| }, {}); // return an object with colors (numbers) as keys and quantity as value | |
| Object.keys(colors).forEach((n) => { // for each key in colors | |
| let _pair = parseInt(colors[n] / 2); // looks for even numbers | |
| if (_pair >= 1) pairs += _pair; // total |
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
| // Without reduce | |
| function diagonalDifference(arr) { | |
| let sum = 0; | |
| for (let i = 0; i <= arr.length - 1; i++) { | |
| sum += arr[i][i] - arr[i].reverse()[i]; | |
| } | |
| return Math.abs(sum); | |
| } | |
| // With reduce |
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
| lista = [] | |
| agenda = {} | |
| def listAll(): | |
| print('----- AGENDA -----') | |
| for i in lista: | |
| for chave, valor in i.items(): | |
| print(chave.title(), valor) | |
| print('----- FIM -----') |
OlderNewer