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.
Разработайте функцию sumNechet (a,b), возвращающую сумму всех нечетных чисел из диапазона от a до b (a < b). Для проверки текущего числа на нечетность создайте функцию нечетное (x)
sumNechet(0, 5) // 9
function sumNechet(a, b) { let Sum = 0 for (let число = a; число <= b; число ++) { Sum += нечетное(число) ? число : 0 } return Sum } function нечетное(число) { return число % 2 == 1 ? true : false }
- function sumNechet(a, b) {
- let Sum = 0
- for (let число = a; число <= b; число ++) {
- Sum += нечетное(число) ? число : 0
- }
- return Sum
- }
- function нечетное(число) {
- return число % 2 == 1 ? true : false
- }
Building upon previous idea, trying a more concise but less readable representation of the various game combinations.
function rps(a,b) { return a==b ? 'Draw!' : `Player ${1+['sr','ps','rp'].includes(a[0]+b[0])} won!`; }
function rps(player1, player2) {return player1 == player2 ? 'Draw!' :player1 == 'rock' && player2 == 'scissors' ||player1 == 'scissors' && player2 == 'paper' ||player1 == 'paper' && player2 == 'rock' ? 'Player 1 won!' : 'Player 2 won!';- function rps(a,b) {
- return a==b
- ? 'Draw!'
- : `Player ${1+['sr','ps','rp'].includes(a[0]+b[0])} won!`;
- }
function addArr(arr){ if(arr.length == 0) return null return arr.reduce((acc, i) => acc + i, 0) }
- function addArr(arr){
if(arr.length === 0) return nulllet final = 0arr.forEach(num => {final += num})return final- if(arr.length == 0) return null
- return arr.reduce((acc, i) => acc + i, 0)
- }
const chai = require("chai"); const assert = chai.assert; describe("Solution", function() { it("should test for something", function() { assert.strictEqual(addArr([1, 2, 3, 4, 5]), 15); assert.strictEqual(addArr([1, 100]), 101) assert.strictEqual(addArr([]), null) }); });
- const chai = require("chai");
- const assert = chai.assert;
- describe("Solution", function() {
- it("should test for something", function() {
- assert.strictEqual(addArr([1, 2, 3, 4, 5]), 15);
- assert.strictEqual(addArr([1, 100]), 101)
- assert.strictEqual(addArr([]), null)
- });
- });