Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.

You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.

A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.

Ad
Ad
Code
Diff
  • function a() {
      return Promise.resolve('ok');
      //return 'ok';
    }
    
    async function b() {
      try {
        const res = await a();
        console.log(res);
        
        return res;
      } catch(err) {
        console.error(err);
      }
    }
    
    • function a() {
    • return new Promise(function (resolve, reject) {
    • resolve('ok');
    • });
    • return Promise.resolve('ok');
    • //return 'ok';
    • }
    • function b() {
    • a().then(function(res) {
    • async function b() {
    • try {
    • const res = await a();
    • console.log(res);
    • }).catch(function(err) {
    • console.log(err);
    • })
    • }
    • return res;
    • } catch(err) {
    • console.error(err);
    • }
    • }
Code
Diff
  • function monteCarlo() {
      return new Promise(function (resolve, reject) {
        reject({server: 'down'});
      });
    }
    
    async function main() {
    
      // converter para ES6
      try {
        const results = await monteCarlo();
      } catch(e) {
        console.error(e);
      }
      
      return true;
    }
    • function monteCarlo() {
    • return new Promise(function (resolve, reject) {
    • reject({server: 'down'});
    • });
    • }
    • async function main() {
    • // converter para ES6
    • const results = await monteCarlo();
    • try {
    • const results = await monteCarlo();
    • } catch(e) {
    • console.error(e);
    • }
    • return true;
    • }
Code
Diff
  • const main = () => {
      
      let links = [
        'https://www.uol',
        'https://www.bol.com.br',
        'https://www.uol',
        'https://noticias.uol.com.br',
        'https://www.bol.com.br',
      ];
      
      return new Set(links);
    };
    • const main = () => {
    • let links = [
    • 'https://www.uol',
    • 'https://www.bol.com.br',
    • 'https://www.uol',
    • 'https://noticias.uol.com.br',
    • 'https://www.bol.com.br',
    • ];
    • // converter para ES6
    • var uniqueLinks = links.reduce(function (carry, item) {
    • if (carry.indexOf(item) === -1) {
    • carry.push(item);
    • }
    • return carry;
    • }, []);
    • return uniqueLinks.length;
    • return new Set(links);
    • };
Code
Diff
  • // 1 - Encontre  um número maior que 6
    var arr = [1, 4, 6, 8, 10];
    var resp = null;
    for (var i = 0; i < arr.length; ++i) {
    	if (arr[i] > 6) {
    		resp = arr[i];
    		break;
    	}
    }
    
    arr.find(v => v > 6);
    
    // 2 - Encontre o índice de um número maior que 6
    var arr = [1, 4, 6, 8, 10];
    var resp = null;
    for (var i = 0; i < arr.length; ++i) {
    	if (arr[i] > 6) {
    		resp = i;
    		break;
    	}
    }
    
    arr.findIndex(v => v > 6);
    
    
    // 3 - Encontre os numeros maiores que 6
    var arr = [1, 4, 6, 8, 10];
    var resp = arr.reduce((carry, item) => {
      if (item > 6)
        carry.push(item);
      return carry;
    }, []);
    
    arr.filter(v => v > 6);
    
    // 4 - O array contém o número 6?
    var arr = [1, 4, 6, 8, 10];
    var resp = arr.indexOf(6) > -1;
    
    arr.includes(6)
    
    
    
    // 5 - Todos os números do array são números pares?
    var arr = [2, 4, 6, 8, 9];
    var resp = true;
    for (var i = 0; i < arr.length; ++i) {
      if (arr[i] % 2 !== 0) {
        resp = false;
        break;
      }
    }
    
    arr.every(v => v % 2 === 0)
    
    // 6 - Algum número no array é impar?
    var arr = [2, 4, 0, -2];
    var resp = arr.reduce(function (carry, item) {
      return carry || (item % 2 !== 0);
    }, false);
    
    arr.some(v => v % 2 !== 0)
    
    • // 1 - Encontre um número maior que 6
    • var arr = [1, 4, 6, 8, 10];
    • var resp = null;
    • for (var i = 0; i < arr.length; ++i) {
    • if (arr[i] > 6) {
    • resp = arr[i];
    • break;
    • }
    • }
    • arr.find(v => v > 6);
    • // 2 - Encontre o índice de um número maior que 6
    • var arr = [1, 4, 6, 8, 10];
    • var resp = null;
    • for (var i = 0; i < arr.length; ++i) {
    • if (arr[i] > 6) {
    • resp = i;
    • break;
    • }
    • }
    • arr.findIndex(v => v > 6);
    • // 3 - Encontre os numeros maiores que 6
    • var arr = [1, 4, 6, 8, 10];
    • var resp = arr.reduce((carry, item) => {
    • if (item > 6)
    • carry.push(item);
    • return carry;
    • }, []);
    • arr.filter(v => v > 6);
    • // 4 - O array contém o número 6?
    • var arr = [1, 4, 6, 8, 10];
    • var resp = arr.indexOf(6) > -1;
    • arr.includes(6)
    • // 5 - Todos os números do array são números pares?
    • var arr = [2, 4, 6, 8, 9];
    • var resp = true;
    • for (var i = 0; i < arr.length; ++i) {
    • if (arr[i] % 2 !== 0) {
    • resp = false;
    • break;
    • }
    • }
    • arr.every(v => v % 2 === 0)
    • // 6 - Algum número no array é impar?
    • var arr = [2, 4, 0, -2];
    • var resp = arr.reduce(function (carry, item) {
    • return carry || (item % 2 !== 0);
    • }, false);
    • }, false);
    • arr.some(v => v % 2 !== 0)
Code
Diff
  • class Component {
      constructor(dom) {
        this.dom = dom;
      }
      
      onCreate() {
        return this.dom;
      }
    }
    
    • function Component(dom) {
    • this.dom = dom;
    • this.onCreate = function() {
    • class Component {
    • constructor(dom) {
    • this.dom = dom;
    • }
    • onCreate() {
    • return this.dom;
    • }
Code
Diff
  • function todo() {
      return 'Walk';
    }
    
    // reescrever em ES6
    (() => {
    
      function todo() {
        return 'Run';
      }
    
    })();
    
    • function todo() {
    • return 'Walk';
    • }
    • // reescrever em ES6
    • (function() {
    • (() => {
    • function todo() {
    • return 'Run';
    • }
    • })();

This is the way to define all of the variables using basically one line of code.

Code
Diff
  • const materia = {
      conteudo: {
        titulo: 'UOL',
      },
      tags: ['São Paulo', 'SP', 'Sudeste', 'Brasil', 'América Latina']
    };
    
    const { conteudo: {titulo}, tags: [,uf, regiao] } = materia;
    • const materia = {
    • conteudo: {
    • titulo: 'UOL',
    • },
    • tags: ['São Paulo', 'SP', 'Sudeste', 'Brasil', 'América Latina']
    • };
    • let [uf, regiao, titulo] = [materia.tags[1], materia.tags[2], materia.conteudo.titulo];
    • /*var uf = materia.tags[1];
    • var regiao = materia.tags[2];
    • var titulo = materia.conteudo.titulo;*/
    • const { conteudo: {titulo}, tags: [,uf, regiao] } = materia;
Code
Diff
  • class Component {
      constructor(dom) {
        console.log('Parent class constructor executed!');
        this.dom = dom;
      }
      
      onCreate() {
        return true;
      }
    }
    
    
    class Collection extends Component{
      constructor(el, created){
        super(el);
      }
    }
    new Collection('#body', true);
    • class Component {
    • constructor(dom) {
    • console.log('Parent class constructor executed!');
    • this.dom = dom;
    • }
    • onCreate() {
    • return true;
    • }
    • }
    • class Collection {
    • //
    • }
    • class Collection extends Component{
    • constructor(el, created){
    • super(el);
    • }
    • }
    • new Collection('#body', true);
Code
Diff
  • var title = 'UOL - O melhor conteúdo';
    
    var share = {
      fb: {
        title
      },
      twitter: {
        tweet: title
      }
    };
    • var title = 'UOL - O melhor conteúdo';
    • var share = {
    • fb: {
    • title: title
    • title
    • },
    • twitter: {
    • tweet: title
    • }
    • };
Code
Diff
  • var bg = 'gray';
    
    var css = `
      <style>
      body {
      background: ${bg};
      color: black;
      }
      </style>`;
      
    
    • var bg = 'gray';
    • var css = '' +
    • '<style>' +
    • 'body {' +
    • ' background: '+ bg + ';' +
    • ' color: black;'
    • '}' +
    • '</style>';
    • var css = `
    • <style>
    • body {
    • background: ${bg};
    • color: black;
    • }
    • </style>`;