🏳️🌈
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
| // não irã funcionar, leia abaixo a explicação. | |
| const resultado = objeto | |
| |> removeNullish | |
| |> makeLowerCase | |
| |> addId |
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 resultado = addId(makeLowerCase(removeNullish(objeto))); |
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 hasMoreCharactersThan = (desired) => (value) => { | |
| const size = value?.length; | |
| if(size < desired) { | |
| throw new Error(`Value is not more than ${desired} characters`); | |
| } | |
| return value; | |
| } | |
| const isValidDescription = hasMoreCharactersThan(100); | |
| const isValidEmail = hasMoreCharactersThan(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
| /** | |
| * @nosideeffects | |
| * @param obj {Object} | |
| * @param props {string[]} | |
| * @return {Object} | |
| */ | |
| function makeLowerCase(obj, props) { | |
| const _obj = { ...obj }; | |
| for (let prop of props) { | |
| _obj[prop] = obj[prop].toLowerCase(); |
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 pessoa = { | |
| nome: 'mathias', | |
| idade: 26, | |
| profissoes: ['desenvolvedor', 'professor'], | |
| } | |
| const { profissoes } = pessoa; | |
| const [ _, segundaProfissao ] = profissoes; | |
| console.log(segundaProfissao); // professor |
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 pessoa = { | |
| nome: 'mathias', | |
| idade: 26, | |
| profissoes: ['desenvolvedor', 'professor'], | |
| } | |
| const { profissoes } = pessoa; | |
| const [ primeiraProfissao, segundaProfissao ] = profissoes; | |
| console.log(primeiraProfissao); // desenvolvedor |
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 somar(...params) { | |
| return params.reduce((acc, curr) => acc + curr, 0); | |
| } |
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 _somar(a, b) { | |
| return a + b; | |
| } | |
| function __somar(a, b, ...restante) { | |
| return a + b; | |
| } | |
| function ___somar(...params) { | |
| return params[0] + params[1]; |
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 somar(a, b) { | |
| return a + b; | |
| } | |
| somar(2, 2, 2); |
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 atualizacao = { | |
| nome: 'mathias', | |
| } | |
| const pessoa = { | |
| nome: 'matias', | |
| idade: 26, | |
| ...atualizacao, | |
| } |
NewerOlder