{"id":16364403,"url":"https://github.com/levinigor/codewars","last_synced_at":"2026-03-18T19:11:19.223Z","repository":{"id":183785263,"uuid":"670739403","full_name":"LevinIgor/Codewars","owner":"LevinIgor","description":"This repository contains solutions to various coding challenges from CodeWars implemented in JavaScript. CodeWars is a platform where developers can improve their programming skills by solving programming puzzles called \"kata\".","archived":false,"fork":false,"pushed_at":"2024-03-21T17:11:35.000Z","size":153,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-30T07:09:42.278Z","etag":null,"topics":["codewars","codewars-javascript","codewars-kata","codewars-solutions","education","solutions","task"],"latest_commit_sha":null,"homepage":"https://www.codewars.com","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LevinIgor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-25T18:13:21.000Z","updated_at":"2024-03-21T11:57:35.000Z","dependencies_parsed_at":"2024-12-31T16:01:01.408Z","dependency_job_id":"248e7fd5-5c65-4bfa-9825-9d540613a8a2","html_url":"https://github.com/LevinIgor/Codewars","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":"0.16129032258064513","last_synced_commit":"e50c5d104b8b28c11306d716cdbf310be97ac4c7"},"previous_names":["levinigor/codeward","levinigor/codewars"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LevinIgor/Codewars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LevinIgor%2FCodewars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LevinIgor%2FCodewars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LevinIgor%2FCodewars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LevinIgor%2FCodewars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LevinIgor","download_url":"https://codeload.github.com/LevinIgor/Codewars/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LevinIgor%2FCodewars/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28765048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T02:25:41.078Z","status":"ssl_error","status_checked_at":"2026-01-26T02:24:28.809Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codewars","codewars-javascript","codewars-kata","codewars-solutions","education","solutions","task"],"created_at":"2024-10-11T02:29:58.515Z","updated_at":"2026-01-26T02:32:07.298Z","avatar_url":"https://github.com/LevinIgor.png","language":null,"readme":"# **JavaScript Collection of solved tasks from the [codewars](https://www.codewars.com) site**\n\n\nThere will be examples of solutions, **I do not recommend using the offered code to solve your tasks**. I want to warn you that if you try to use the answers shown, you are likely **to be blocked by the site**. The repository was created primarily as a collection of examples for possible study, and help newcomers.\n\n\n![](https://www.codewars.com/users/3au4onok/badges/small)\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/t/LevinIgor/Codewars)\n![GitHub Repo stars](https://img.shields.io/github/stars/LevinIgor/Codewars)\n![GitHub forks](https://img.shields.io/github/forks/LevinIgor/Codewars)\n![GitHub contributors](https://img.shields.io/github/contributors/LevinIgor/codewars)\n![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/LevinIgor/Codewars)\n![GitHub last commit](https://img.shields.io/github/last-commit/LevinIgor/codewars)\n\n\n# **Kata**\n\n  - **[8 - kyu](#8-kyu)** \u003cbr\u003e\n  - **[7 - kyu](#7-kyu)** \u003cbr\u003e\n  - **[6 - kyu](#6-kyu)** \u003cbr\u003e\n  - **[5 - kyu](#5-kyu)** \u003cbr\u003e\n  - **[4 - kyu](#4-kyu)** \u003cbr\u003e\n  - **[3 - kyu](#3-kyu)** \u003cbr\u003e\n  - **[2 - kyu](#2-kyu)** \u003cbr\u003e\n  - **[1 - kyu](#1-kyu)** \u003cbr\u003e \n\u003cbr\u003e\n\n\n## 8 Kyu\n\n  - ### Heads and Legs | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n    function animals(heads, legs){\n      for(var i = 0; i \u003c= heads; i++){\n        if( (i * 4 + (heads- i) * 2) == legs){\n          return [heads- i,i];\n        }\n      }\n      return 'No solutions';\n    }\n\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Hello, Name or World! | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n    \n    const hello = name =\u003e return `Hello, ${name ? name.at(0).toUpperCase() + name?.slice(1).toLowerCase() : 'World'}!`\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### A Strange Trip to the Market | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const isLockNessMonster = s =\u003e s.includes('tree fiddy') || s.includes('3.50') || s.includes('three fifty')\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Add new item (collections are passed by reference) | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const addExtra = listOfNumbers =\u003e [...listOfNumbers,'cock']\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Exclamation marks series #4: Remove all exclamation marks from sentence but ensure a exclamation mark at the end of string | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const remove = string =\u003e string.replace(/!/g, '') + '!'\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n\n  - ### Exclamation marks series #2: Remove all exclamation marks from the end of sentence | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const remove = s =\u003e s.replace(/!+$/, '');\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Grasshopper - Variable Assignment Debug | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    var a = \"dev\"\n    var b = \"Lab\"\n    \n    var name = a + b\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Return Two Highest Values in List | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const twoHighest = arr =\u003e [...new Set(arr)].sort((a,b) =\u003e a-b).slice(-2).reverse()\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### How old will I be in 2099? | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const calculateAge = (m, n) =\u003e {\n      if(m == n) return 'You were born this very year!';\n    \n      const year = Math.abs(m-n) == 1 ? 'year' : 'years';\n    \n      if(m \u003c n) return \"You are \"+(n-m)+' '+year+' old.';\n      if(m \u003e n) return \"You will be born in \"+(-n+m)+' '+year+'.';\n    }\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Ensure question  | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const ensureQuestion = s =\u003e s.endsWith('?') ? s : s + '?'\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Total pressure calculation  | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function solution(M1, M2, m1, m2, V, T) {\n    \t\tM1 = m1 * 0.001/M1;\n        M2 = m2 * 0.001/M2;\n        T = T + 273.15;\n    \t  const R = 0.082;\n    \n    \t  return (((M1 + M2) * R * T) / V) * 1000;\n    }\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Enumerable Magic #1 - True for All? | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const all = ( arr, fun ) =\u003e arr.every(fun)\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Parse float | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const parseF = s =\u003e  isNaN(parseFloat(s)) ? null : parseFloat(s)\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### SpeedCode #2 - Array Madness | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const arrayMadness = (a, b) =\u003e a.reduce((acc, x) =\u003e acc + x**2, 0) \u003e b.reduce((acc, x) =\u003e acc + x**3, 0) \n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### easy logs | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const logs = (x , a, b) =\u003e  (Math.log(a*b) / Math.log(x))\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Classy Classes | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    class Person {\n\n      constructor(name, age) {\n        this.name = name;\n        this.age = age;\n      }\n      \n      get info() {\n        return `${this.name}s age is ${this.age}`;\n      }\n    }\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Pole Vault Starting Marks | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const startingMark = bodyHeight =\u003e +(bodyHeight * 3.9354 + 3.4681).toFixed(2);\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Training JS #6: Basic data types--Boolean and conditional statements if..else | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const trueOrFalse =(val) =\u003e Boolean(val).toString()\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Fuel Calculator: Total Cost | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function fuelPrice(litres, pricePerLiter) {\n      var discount = Math.min(Math.floor(litres/2) * 0.05, 0.25);\n      var price = litres * (pricePerLiter - discount);\n      return Math.round(price*100) / 100;\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### Days in the year | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const yearDays = year =\u003e `${year} has 36${6 - !!(year % 400 \u0026\u0026 !(year % 100) || year % 4)} days`;\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Arguments to Binary addition | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const arr2bin = arr =\u003e arr.filter(x =\u003e typeof x == 'number').reduce((x, y) =\u003e x + y, 0).toString(2);\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Training JS #34: methods of Math---pow() sqrt() and cbrt() | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function cutCube(volume,n){\n      return !(Math.cbrt(n) % 1) \u0026\u0026 !(Math.cbrt(volume / n) % 1);\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Training JS #17: Methods of String object--indexOf(), lastIndexOf() and search() | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const firstToLast = (str,c) =\u003e (str.indexOf(c) \u003c 0) ? -1 : str.lastIndexOf(c) - str.indexOf(c)\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Implement Array.prototype.filter() | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    Array.prototype.filter = function (func) {\n      const result = []\n      this.forEach(el =\u003e func(el) ? result.push(el) : null)      \n      return result\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Job Matching #1 | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function match(candidate, job) {\n        if(!candidate.minSalary || !job.maxSalary) throw \"Error!!\";\n        return (candidate.minSalary * 0.9) \u003c= job.maxSalary;\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Lexical this | 8 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n     var Person = function(){\n        var person = {\n          _name: \"Leroy\",\n          _friends: [],\n          fillFriends(f){\n            this._friends.push(...f);\n          }\n        }\n        return person;\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n## 7 Kyu\n\n  - ### ASCII letters from Number | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function convert(number){\n      const arr = []\n      \n      for(let i = 0; i \u003c number.length; i+=2){\n        arr.push(String.fromCharCode(number.substr(i,2)))\n      }\n      \n      return arr.join('')\n     }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Find the next perfect square! | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function findNextSquare(sq) {\n      return Math.sqrt(sq)%1? -1 : Math.pow(Math.sqrt(sq)+1,2);\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Ones and Zeros | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const binaryArrayToNumber = arr =\u003e {\n      return parseInt(arr.join(\"\"), 2)\n    };\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Sum of the first nth term of Series | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function SeriesSum(n) {\n      var sum = 0;\n      for(var i = 0; i \u003c n; i++) {\n        sum += 1 / (3 * i + 1);\n      }\n      return sum.toFixed(2);\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Sort array by string length | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n     let sortByLength = arr =\u003e arr.sort((a,b) =\u003e a.length - b.length);\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Find the middle element | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n     const gimme = function (arr) {\n        return arr.indexOf([...arr].sort((x, y) =\u003e x \u003e y)[1]);\n     };\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Round up to the next multiple of 5 | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n     function roundToNext5(n){\n        return Math.ceil(n/5)*5;\n      }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Simple Fun #176: Reverse Letter | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n     function reverseLetter(str) {\n        return str.replace(/[^a-z]/gi,'').split('').reverse().join('')  \n    }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Summing a number's digits | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function sumDigits(number) {\n      return `${Math.abs(number)}`.split('').reduce((acc,el) =\u003e acc + +el,0)\n    }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Check the exam | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function checkExam(array1, array2) {\n      let result = 0;\n      \n      for(let i in array1){\n        if(array2[i] === '') continue;\n        array1[i] === array2[i] ? result+=4 : result-=1;\n      }\n      \n      return Math.max(result,0)\n    }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Fix string case | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function solve(s){\n        return s.match(/[a-z]/g).length \u003e= s.length / 2 ? s.toLowerCase() : s.toUpperCase()\n    }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Triangular Treasure | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function triangular( n ) {\n      return n \u003e 0 ? n * (n + 1) / 2 : 0;\n    }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Most digits | 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const findLongest = l =\u003e l.reduce((a, b) =\u003e (`${b}`.length \u003e `${a}`.length) ? b : a);\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Reverse a Number 7 kyu | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const reverseNumber = n =\u003e (n \u003e 0 ? 1 : -1) * Math.abs(n).toString().split('').reverse().join('')\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Minimize Sum Of Array (Array Series #1) | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function minSum(arr) {\n      const l = arr.length;\n      const sorted = arr.sort((a, b) =\u003e b - a);\n      const max = sorted.slice(0, l/2);\n      const min = sorted.slice(l/2, l).reverse();\n      \n      return max.reduce((sum, el, i) =\u003e sum + el * min[i], 0);\n    }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Moves in squared strings (I) | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const vertMirror = s =\u003e s.map(s =\u003e [...s].reverse().join(''));\n    const horMirror = s =\u003e s.reverse();\n    \n    const oper = (fct, s) =\u003e fct(s.split(\"\\n\")).join(\"\\n\");\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n  - ### All unique | [:arrow_up:UP](#kata)\n    ```javascript\n\n    let hasUniqueChars = (str) =\u003e new Set(str).size === str.length;\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Palindrome chain length | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const palindromeChainLength = n =\u003e {\n      let count = 0;\n    \n      while(+[...`${n}`].reverse().join('') !== n){\n        n+= +[...`${n}`].reverse().join('')\n        count++;\n      }\n      \n      return count\n    };\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Speed Control | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const gps = (s, x) =\u003e {\n\n      if (x.length\u003c=1) {\n        return 0;\n      }\n      \n      let output = [];\n      for (let i = 0; i \u003c x.length-1; i++) { \n        output.push((x[i+1]-x[i])*3600/s);\n      }\n      \n      return Math.max(...output);\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Coding Meetup #2 - Higher-Order Functions Series - Greet developers | [:arrow_up:UP](#kata)\n    ```javascript\n\n     const greetDevelopers = list =\u003e list.map(dev =\u003e ({...dev, greeting: `Hi ${dev.firstName}, what do you like the most about ${dev.language}?`}));\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Halving Sum | [:arrow_up:UP](#kata)\n    ```javascript\n\n     const halvingSum = n =\u003e n \u003e 1 ? n + halvingSum(n / 2 | 0) : n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### max diff - easy | [:arrow_up:UP](#kata)\n    ```javascript\n\n     function maxDiff(list) {\n       return list.length ? Math.max(...list) - Math.min(...list) : 0;\n     };\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Over The Road | [:globe_with_meridians:Source](https://www.codewars.com/kata/5f0ed36164f2bc00283aed07/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n     function maxDiff(list) {\n       return list.length ? Math.max(...list) - Math.min(...list) : 0;\n     };\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Simple beads count | [:globe_with_meridians:Source](https://www.codewars.com/kata/58712dfa5c538b6fc7000569/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n     function countRedBeads(n) {\n       return n \u003c 2 ? 0 : 2 * n - 2;\n     }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Boiled Eggs | [:globe_with_meridians:Source](https://www.codewars.com/kata/52b5247074ea613a09000164/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function cookingTime(eggs) {\n      return 5 * Math.ceil(eggs / 8);\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Simple remove duplicates | [:globe_with_meridians:Source](https://www.codewars.com/kata/5ba38ba180824a86850000f7/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n     function solve(arr){\n       return arr.filter((val,i) =\u003e arr.lastIndexOf(val) == i);\n     }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Find the nth Digit of a Number | [:globe_with_meridians:Source](https://www.codewars.com/kata/577b9960df78c19bca00007e/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    var findDigit = function(num, nth){\n      if(nth \u003c= 0) return -1\n      num = `${Math.abs(num)}`\n      \n      return num.length \u003e= nth ? +num.at(num.length - nth) : 0\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### esreveR | [:globe_with_meridians:Source](https://www.codewars.com/kata/5413759479ba273f8100003d/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n     reverse = function(array) {\n       return array.map((c, i) =\u003e array[array.length - 1 - i]);\n     }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Sum of array singles | [:globe_with_meridians:Source](https://www.codewars.com/kata/59f11118a5e129e591000134/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n     function repeats(arr){\n       return arr.reduce((acc,el) =\u003e arr.indexOf(el) === arr.lastIndexOf(el) ? acc+=el : acc,0)\n     };\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Gauß needs help! (Sums of a lot of numbers). | [:globe_with_meridians:Source](https://www.codewars.com/kata/54df2067ecaa226eca000229/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n     function f(n){\n       if(typeof n !== 'number' || !Number.isInteger(n) || n \u003c= 0) return false\n       return ((1 + n)*n)/2\n     };\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Alphabetical Addition | [:globe_with_meridians:Source](https://www.codewars.com/kata/5d50e3914861a500121e1958/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function addLetters(...letters) {\n      const alpha = 'zabcdefghijklmnopqrstuvwxy';\n      const sum = letters.reduce((sum, letter) =\u003e sum + alpha.indexOf(letter), 0) % 26;\n      return alpha[sum];\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Filter the number | [:globe_with_meridians:Source](https://www.codewars.com/kata/55b051fac50a3292a9000025/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const FilterString = value =\u003e +value.replace(/\\D/g, '');\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Simple Fun #74: Growing Plant | [:globe_with_meridians:Source](https://www.codewars.com/kata/58941fec8afa3618c9000184/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function growingPlant(upSpeed, downSpeed, desiredHeight) {\n      let count = 0, height = 0;\n      while(true){\n        count++;\n        height+=upSpeed;\n        if(height \u003e= desiredHeight) return count;\n        height-=downSpeed;\n      }\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Coloured Triangles | [:globe_with_meridians:Source](codewars.com/kata/5a25ac6ac5e284cfbe000111/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function triangle(row) {\n      let result = ''\n      if(row.length == 1) result = row;\n      \n      for(let i = 0; i \u003c row.length - 1; i++){\n        if(row[i] === row[i+1]) result+= row[i]\n        else result+= 'RGB'.replace(row[i],'').replace(row[i+1],'')\n      }\n      \n      if(row.length \u003e 1) return triangle(result)\n      else return result\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Strong Number (Special Numbers Series #2) | [:globe_with_meridians:Source](https://www.codewars.com/kata/5a4d303f880385399b000001/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function strong(n) {\n      return [1,2,145,40585].includes(n) ? 'STRONG!!!!' : 'Not Strong !!'\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Help the Fruit Guy | [:globe_with_meridians:Source](https://www.codewars.com/kata/557af4c6169ac832300000ba/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function removeRotten(arr){\n      return arr ? arr.map(x=\u003ex.replace('rotten', '').toLowerCase()) : [] ;\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Currying functions: multiply all elements in an array | [:globe_with_meridians:Source](https://www.codewars.com/kata/586909e4c66d18dd1800009b/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const multiplyAll = arr =\u003e n =\u003e arr.map(x =\u003e n * x);\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Alternate case | [:globe_with_meridians:Source](https://www.codewars.com/kata/57a62154cf1fa5b25200031e/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function alternateCase(s) {\n      return [...s].map(el =\u003e el === el.toLowerCase() ? el.toUpperCase() : el.toLowerCase()).join('')\n    }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Basic Calculator | [:globe_with_meridians:Source](https://www.codewars.com/kata/5296455e4fe0cdf2e000059f/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function calculate(num1, operation, num2) {\n      var ops = {\n        '+': function(x, y) { return x + y; },\n        '-': function(x, y) { return x - y; },\n        '*': function(x, y) { return x * y; },\n        '/': function(x, y) { return y === 0 ? null : x / y; }\n      };\n      return (ops[operation] || function() { return null; })(num1, num2);\n    }\n\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Disarium Number (Special Numbers Series #3) | [:globe_with_meridians:Source](https://www.codewars.com/kata/5a53a17bfd56cb9c14000003/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function disariumNumber(n){\n      return [...`${n}`].reduce((acc,el,i) =\u003e acc+=el**(i+1),0) === n ? 'Disarium !!' : 'Not !!'\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Building blocks | [:globe_with_meridians:Source](https://www.codewars.com/kata/55b75fcf67e558d3750000a3/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    class Block{\n\n      constructor(data){\n        [this.width, this.length, this.height] = data;\n      }\n      \n      getWidth() {\n        return this.width;\n      }\n      \n      getLength() {\n        return this.length;\n      }\n      \n      getHeight() {\n        return this.height;\n      }\n      \n      getVolume() {\n        return this.width * this.length * this.height;\n      }\n      \n      getSurfaceArea () {\n        return 2 * (this.width * this.length + this.width * this.height + this.length * this.height);\n      }\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### SevenAte9 | [:globe_with_meridians:Source](https://www.codewars.com/kata/559f44187fa851efad000087/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function sevenAte9(str){\n      return str.replace(/79(?=7)/g, '7');\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Difference Of Squares | [:globe_with_meridians:Source](https://www.codewars.com/kata/558f9f51e85b46e9fa000025/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function differenceOfSquares(n){\n      const arr = Array.from({length:n}, (_,i) =\u003e i+1)\n      return arr.reduce((acc,el) =\u003e acc+el,0)**2 - arr.reduce((acc,el) =\u003e acc+=el**2,0)\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Digital cypher | [:globe_with_meridians:Source](https://www.codewars.com/kata/592e830e043b99888600002d/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function encode(str,  n){\n      return  [...str].map((el,i) =\u003e (el.charCodeAt() - 96) + +`${n}`.at(i%`${n}`.length))\n    }\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Return the closest number multiple of 10 | [:globe_with_meridians:Source](https://www.codewars.com/kata/58249d08b81f70a2fc0001a4/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    const closestMultiple10 = num =\u003e Math.round(num / 10) * 10;\n    \n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Substituting Variables Into Strings: Padded Numbers | [:globe_with_meridians:Source](https://www.codewars.com/kata/51c89385ee245d7ddf000001/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function solution(value){\n      return \"Value is \" + (\"00000\" + value).slice(-5);\n    }\n    \n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### The old switcheroo | [:globe_with_meridians:Source](https://www.codewars.com/kata/55d410c492e6ed767000004f/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function vowel2index(str) {\n       return str.replace(/[aeiou]/ig, (m, i) =\u003e i + 1);\n    }\n    \n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Word values | [:globe_with_meridians:Source](https://www.codewars.com/kata/598d91785d4ce3ec4f000018/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n    function wordValue(a) {\n    \treturn a.map((el,i) =\u003e el.replace(/ /g, '').split('').reduce((acc,letter) =\u003e acc+letter.charCodeAt() - 96,0) * (i+1))\n    }\n    \n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Convert a linked list to a string | [:globe_with_meridians:Source](https://www.codewars.com/kata/582c297e56373f0426000098/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tfunction stringify(list) {\n\t\treturn list === null ? \"null\" : `${list.data} -\u003e ${stringify(list.next)}`; \n\t}\n    \n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### ToLeetSpeak | [:globe_with_meridians:Source](https://www.codewars.com/kata/57c1ab3949324c321600013f/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tconst toLeetSpeak = s =\u003e s.replace(/[ABCEGHILOSTZ]/g, c =\u003e D[c]);   \n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Split In Parts | [:globe_with_meridians:Source](https://www.codewars.com/kata/5650ab06d11d675371000003/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tvar splitInParts = function(s, partLength){\n\t  let result = []\n\t  \n\t  for(let i = 0; i \u003c s.length; i+=partLength){\n\t    result.push(s.substr(i,partLength))\n\t  }\n\t  \n\t  return result.join(' ')\n\t}\t\t\n    \n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Valid Spacing | [:globe_with_meridians:Source](https://www.codewars.com/kata/5f77d62851f6bc0033616bd8/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tfunction validSpacing(s) {\n\t  return s.trim() == s \u0026\u0026 !s.includes(\"  \");\n\t}\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Count all the sheep on farm in the heights of New Zealand | [:globe_with_meridians:Source](https://www.codewars.com/kata/58e0f0bf92d04ccf0a000010/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tconst lostSheep = (f,s,n) =\u003e n - [...f,...s].reduce((a,b) =\u003e a + b,0)\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Insert dashes | [:globe_with_meridians:Source](https://www.codewars.com/kata/55960bbb182094bc4800007b/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tfunction insertDash(num) {\n\t  let result = ''\n\t  num = `${num}`\n\t  for(let i = 0; i \u003c num.length; i++){\n\t    if(num[i]\u00261 \u0026\u0026 num[i+1]\u00261) result+=`${num[i]}-`\n\t    else result+=num[i]\n\t  }\n\t  \n\t  return result\n\t}\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Band name generator | [:globe_with_meridians:Source](https://www.codewars.com/kata/59727ff285281a44e3000011/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tfunction bandNameGenerator(str) {\n\t  return str.at(0) !== str.at(-1) ? `The ${str.at(0).toUpperCase() + str.slice(1)}` : `${str.charAt(0).toUpperCase() + str.slice(1) + str.slice(1)}`\n\t}\n    \n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Arithmetic progression | [:globe_with_meridians:Source](https://www.codewars.com/kata/55caf1fd8063ddfa8e000018/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tfunction arithmeticSequenceElements(a, r, n) {\n\t  return Array.from({length: n}, (_, i) =\u003e a + r * i).join(', ');\n\t}\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Stanton measure | [:globe_with_meridians:Source](https://www.codewars.com/kata/59a1cdde9f922b83ee00003b/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n  \tfunction stantonMeasure(arr) {\n\t  const count = n =\u003e arr.filter(x =\u003e x === n).length;\n\t  return count(count(1));\n\t}\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Length and two values. | [:globe_with_meridians:Source](https://www.codewars.com/kata/62a611067274990047f431a8/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n\tfunction alternate(n, firstValue, secondValue){\n\t  return Array.from({length:n}, (_,i) =\u003e i\u00261 ?  secondValue : firstValue)\n\t}\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### makeBackronym | [:globe_with_meridians:Source](https://www.codewars.com/kata/55805ab490c73741b7000064/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n\tvar makeBackronym = function(string){\n\t  return [...string].map(el =\u003e dict[el.toUpperCase()]).join(' ');\n\t};\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Frequency sequence | [:globe_with_meridians:Source](https://www.codewars.com/kata/585a033e3a36cdc50a00011c/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n\tfunction freqSeq(str, sep) {\n\t  return [...str].map(el =\u003e str.replace(new RegExp(`[^${el}]`,'g'),'').length).join(sep)\n\t}\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Find Duplicates | [:globe_with_meridians:Source](https://www.codewars.com/kata/5558cc216a7a231ac9000022/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n\tconst duplicates = arr =\u003e [...new Set(arr.filter((el, i) =\u003e i !== arr.indexOf(el)))];\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### TV Remote | [:globe_with_meridians:Source](https://www.codewars.com/kata/5a5032f4fd56cb958e00007a/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n\tconst tvRemote = function(word) {\n  \n\t  let keys = 'abcde123fghij456klmno789pqrst.@0uvwxyz_/';\n\t  let pos = [ 0, 0 ];\n\t  let res = 0;\n\t  \n\t  for (let char of word) {\n\t\n\t    let i = keys.indexOf(char);\n\t    let dest  = [ i / 8 | 0, i % 8 ];\n\t\n\t    res += Math.abs(dest[0] - pos[0]) + Math.abs(dest[1] - pos[1]) + 1;\n\t    pos = dest;\n\t    \n\t  }\n\t\n\t  return res;\n\t\n\t}\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n  - ### Delta Bits | [:globe_with_meridians:Source](https://www.codewars.com/kata/538948d4daea7dc4d200023f/javascript)  | [:arrow_up:UP](#kata)\n    ```javascript\n\n\tfunction convertBits(a, b){\n\t  var x = a ^ b, count = 0;\n\t  do { count += x \u0026 1 } while (x \u003e\u003e= 1);\n\t  return count;\n\t}\n\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n## 6 Kyu\n  - ### Random Sequence Generator | [:globe_with_meridians:Source](https://www.codewars.com/kata/5302b069ad5217ce2d0000f1/javascript)  | [:arrow_up:UP](#kata)\n    \n    ```javascript\n\n\tfunction Randomizer(min, max) {\n\t  for (this.num = []; min \u003c= max; min++) this.num.push(min)\n\t  for (var i = 10; i--;) this.num.sort(function() { return Math.random() - 0.5 })\n\t}\n\t\n\tRandomizer.prototype.next = function() {\n\t  if (!this.num.length) throw new Error('No more numbers')\n\t\treturn this.num.pop()\n\t}\n\t\n\tRandomizer.prototype.sequence = function(size) {\n\t  if (size \u003e this.num.length || !this.num.length) throw new Error('Too many numbers')\n\t\treturn this.num.splice(0, size || Infinity);\n\t}\n\n    ```\n\n    ``` javascript\n\tfunction Randomizer(min, max) {\n\t  this.numbers = [...'0'.repeat(max-min+1)].map((_, i) =\u003e min + i);\n\t  this.numbers.sort((a, b) =\u003e Math.random() - 0.5);\n\t}\n\t\n\tRandomizer.prototype.next = function() {\n\t  if (this.numbers.length === 0) throw new Error('No more numbers');\n\t  return this.numbers.pop();\n\t};\n\t\n\tRandomizer.prototype.sequence = function(size = this.numbers.length) {\n\t  if (size \u003e this.numbers.length) throw new Error('Too many numbers');\n\t  return this.numbers.splice(0, size);\n\t};\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n\n\n- ### Arc Length | [:globe_with_meridians:Source](https://www.codewars.com/kata/5307ce667da4f26b1600080d/javascript)  | [:arrow_up:UP](#kata)\n    \n    ```javascript\n\n\tfunction distance([x1, y1], [x2, y2]) {\n\t    return Math.hypot(x1 - x2, y1 - y2);\n\t}\n\t\n\tfunction linspace(start, stop, length) {\n\t    const step = (stop - start) / (length - 1);\n\t    return Array.from({length: length}, (_, i) =\u003e start + step * i);\n\t}\n\t\n\tfunction arcLen(fn, range, intervals = 200) {\n\t    const coords = linspace(...range, intervals).map(fn);\n\t    const lengths = Array.from({length: intervals - 1}, (_, i) =\u003e distance(coords[i], coords[i + 1]));\n\t    return parseFloat(lengths.reduce((a, b) =\u003e a + b).toFixed(2));\n\t}\n\n    ```\n\n    ``` javascript\n\tfunction arcLen(fn, [b, e]) {\n\t  const n = 100000;\n\t  let res = 0;\n\t  for (let i = 0, pp; i \u003c n; i++) {\n\t    const p = fn(b * i / n + e * (n - i) / n);\n\t    if (i != 0)\n\t      res += Math.hypot(p[0] - pp[0], p[1] - pp[1]);\n\t    pp = p;\n\t  }\n\t  return res;\n\t}\n    ```\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n- ### Quantum Bogosort | [:globe_with_meridians:Source](https://www.codewars.com/kata/53165ceea8fbdb4e0c00015b/javascript)  | [:arrow_up:UP](#kata)\n    \n    ```javascript\n\n\tArray.prototype.qbsort = function() {\n\t  this.qshuffle()  \n\t  this.some((_,i,a) =\u003e i \u0026\u0026 a[i]\u003ca[i-1] ) \u0026\u0026 QSC.destroyUniverse();\n\t}\n\n    ```\n\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \n## 5 Kyu\n## 4 Kyu\n## 3 Kyu\n## 2 Kyu\n## 1 Kyu\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevinigor%2Fcodewars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flevinigor%2Fcodewars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevinigor%2Fcodewars/lists"}