- Um nível de recuo por método.
- Não use a palavra-chave ELSE.
- Envolver todos os primitivos e Strings em classes. (em JS nao eh necessario)
- Funções de primeira classe // mudei p/ Function em vez de Class
- Um ponto por linha.
- Não abrevie.
- Mantenha todas os módulos com menos de 50 linhas.
- Nenhuma função com mais de dois parâmetros.
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 plus = ( a = 0 ) => ( b = 0 ) => a + b | |
const times = ( a = 1 ) => ( b = 1 ) => a * b | |
const minus = ( a = 0 ) => ( b = 0 ) => a - b | |
const division = ( a = 1 ) => ( b = 1 ) => a / b | |
const getNumByIndex = ( num, index ) => num[index] | |
const applyFn = ( fn ) => ( x, y ) => fn( x )( y) | |
const applyVerticalOperation = ( fn) => ( acc, cur) => |
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
$(function() { | |
const medida_el = document.querySelector('#validacao_medida_id_val') | |
const dimensao_el = document.querySelector('#validacao_dimensao_id_val') | |
console.log(medida_el) | |
console.log(dimensao_el) | |
const changeMedida = (event) => { |
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
$(function() { | |
var dimensoes_val, medidas_val; | |
$('#validacao_medida_id_val').parent().hide(); | |
$('#validacao_dimensao_id_val').parent().hide(); | |
medidas_val = $('#validacao_medida_id_val').html(); | |
dimensoes_val = $('#validacao_dimensao_id_val').html(); | |
console.log("medidas: "+medidas_val); | |
console.log("dimensoes: "+dimensoes_val); |
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
// Variables | |
const numbers = [8, 6, 9]; | |
const weights = [3, 1, 6]; | |
// Helpers | |
const sum = (val1, val2) => val1 + val2; | |
const reduce = (numbers, fn) => numbers.reduce(fn); | |
const rtnLength = array => array.length; | |
const compareNumbers = (n1, n2) => n1 - n2; |
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
/* "Thunks, Trampolines, and Continuation Passing" | |
* Python implementation from http://jtauber.com/blog/2008/03/30/ | |
* JavaScript implementation by Thomas Darr <me@trdarr.com>. | |
*/ | |
// thunk = lambda name: lambda *args: lambda: name(*args) | |
var thunk = function thunk(fn) { | |
return function _thunk() { | |
var splat = Array.prototype.slice.apply(arguments); | |
return function __thunk() { return fn.apply(this, splat); }; |
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 mensagem = prompt('Digite sua mensagem'); | |
const cifra = parseInt(prompt('Digite o valor da cifra')); | |
let mensagemCodificada = '' | |
for (var i = 0, length = mensagem.length; i < length; i++) { | |
mensagemCodificada += String.fromCharCode(mensagem.charCodeAt(i) + cifra); | |
} | |
alert(mensagemCodificada); |
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
function criaArrayPrimos(x) { | |
return [...Array(x).keys()].slice(2).filter(ehPrimo) | |
} | |
function ehPrimo(x){ | |
return [...Array(Math.ceil(Math.sqrt(x + 1))).keys()].slice(2).every(y => x % y !== 0) | |
} | |
console.log(criaArrayPrimos(40)) //[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 ] |
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
function criaArrayPrimos(x) { | |
return [...Array(x).keys()].slice(2).filter(ehPrimo) | |
} | |
function ehPrimo(x){ | |
return [...Array(Math.ceil(Math.sqrt(x + 1))).keys()].slice(2).every(y => x % y !== 0) | |
} | |
console.log(criaArrayPrimos(40)) //[ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 ] |
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 matrix = [[2,4,6,8],[12,14,16,18],[20,24,28,32],[32,34,36,38],[42,44,46,48]]; | |
const exp = matrix[0]; | |
const arrNumbers = matrix.slice(1); | |
const props = [ | |
(number, _i) => (number * exp[_i]), | |
(number, _i) => (number / exp[_i]), | |
(number, _i) => (number - exp[_i]), | |
(number, _i) => (number + exp[_i]) | |
]; | |
const op = (arr, _i) => arr.map(_a => props[_i](_a, _i)); |