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
| var Alphabet = { | |
| "01100001": "a", | |
| "01100010": "b", | |
| "01100011": "c", | |
| "01100100": "d", | |
| "01100101": "e", | |
| "01100110": "f", | |
| "01100111": "g", | |
| "01101000": "h", | |
| "01101001": "i", |
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 steamrollArray(arr) { | |
| // I'm a steamroller, baby | |
| var arrStr = arr.toString().split(",") | |
| var isStrNaN = (str) => { | |
| if (str === "") return true | |
| return isNaN(Number(str)) | |
| } | |
| var isStrObject = (str) => str === "[object Object]" |
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 dropElements(arr, func) { | |
| // Drop them elements. | |
| var arrTrue = arr.map(func) | |
| var first = arrTrue.indexOf(true) | |
| var last = arrTrue.lastIndexOf(true) | |
| return arr.slice(first, last + 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 smallestCommons(arr) { | |
| var sortArrays = arr => arr.sort((x, y) => x - y) | |
| var seqBetween = (init, end) => { | |
| return Array(end - init + 1).fill().map((it, i) => init + i) | |
| } | |
| const organizedArr = sortArrays(arr) | |
| const [init, end] = organizedArr | |
| const seqArr = seqBetween(init, end) |
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 sumPrimes(num) { | |
| var isDivisable = (dividend, divisor) => dividend % divisor === 0; | |
| var isPrime = num => { | |
| var treshold = Math.ceil(num / 2); | |
| var isNumberPrime = (num, treshold) => { | |
| if (treshold === 1) return true; | |
| if (isDivisable(num, treshold)) return false | |
| return isNumberPrime(num, treshold - 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 sumFibs(num) { | |
| const fibonacci = num => { | |
| if(num === 0) return 1; | |
| if(num === 1) return 1; | |
| return fibonacci(num - 1) + fibonacci(num - 2) | |
| } | |
| const isOdd = num => num % 2 > 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 convertHTML(str) { | |
| // :) | |
| return str.replace(/&/g, "&"). | |
| replace(/</g, "<"). | |
| replace(/>/g, ">"). | |
| replace(/"/g, """). | |
| replace(/'/g, "'"); | |
| } | |
| console.log(convertHTML("Dolce & Gabbana")); |
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 uniteUnique(arr) { | |
| var getArgsArr = (args) => { | |
| var finalList = [] | |
| for (var i in args) { | |
| finalList.push(args[i]) | |
| } | |
| return finalList.flat() | |
| } |
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 fearNotLetter(str) { | |
| const letters = "abcdefghijklmnopqrstuvwxyz" | |
| const strArr = str.split("") | |
| const posInAlphabet = char => letters.indexOf(char) | |
| const diffPos = (char1, char2) => posInAlphabet(char2) - posInAlphabet(char1); | |
| const returnLetter = (strArr) => { | |
| if (strArr.length === 1) return undefined; | |
| const [x, ...xy] = strArr |
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 translatePigLatin(str) { | |
| const getFirstVow = str => str.search(/a|e|i|o|u/) | |
| const firstVow = getFirstVow(str) | |
| if(firstVow > 0) return `${str.slice(firstVow)}${str.slice(0, firstVow)}ay` | |
| if(firstVow === 0) return `${str}way` | |
| return str + 'ay'; | |
| } | |
| console.log(translatePigLatin("consonant")); |