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 test(arr) { | |
| let max = 0; | |
| let result = ''; | |
| const obj = {}; | |
| let maxO = 0; | |
| let maxAnimal = ''; | |
| arr.forEach(item => { | |
| const a = item.split(''); | |
| if (a.length > max) { |
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 numberOfWaysToPay(denominations, denominationCount, rent) { | |
| const ways = []; | |
| for (let i = 0; i <= rent; i++) { | |
| ways.push(0); | |
| } | |
| ways[0] += 1; | |
| for (let j = 0; j < denominations; j++) { | |
| const coin = denominationCount[j]; |
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 solution(data) { | |
| let degree = 1; | |
| let degreePos = data[0]; | |
| const map = new Map(); | |
| for (let i = 0; i < data.length; i++) { | |
| const element = data[i]; | |
| if (map.has(element)) { | |
| const pos = map.get(element); |
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 count_digits(d, n) { | |
| let count = 0; | |
| for (let index = 0; index <= n; index++) { | |
| const a = index.toString(); | |
| if (d == a) { | |
| count++; | |
| } | |
| if (a.length > 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
| var path = require('path') | |
| var funcs = require('./funcs') | |
| var session = { | |
| username: process.argv[2], | |
| lastMessageHash: process.argv[3] | |
| } | |
| if (!session.username || !session.lastMessageHash) { | |
| console.log('Usage: node index.js <username> <hash>') |
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() { | |
| 'use strict'; | |
| function parseHTMLMenu(fs) { | |
| let html = '<ul>'; | |
| for (let key in fs) { | |
| const element = fs[key]; | |
| html += '<li>'; | |
| if (Array.isArray(element.sub)) { | |
| html += element.txt; | |
| html += parseHTMLMenu(element.sub); |
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 parseElement(element) { | |
| if (element.length === 1) { | |
| return `</${element[0]}>`; | |
| } | |
| if (Array.isArray(element)) { | |
| let tag = element.shift(); | |
| let toReturn = `<${tag}>`; | |
| toReturn = element.reduce((result, el) => { | |
| if (el) { |
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 averageColors(color1, color2) { | |
| const c1 = splitColor(color1), | |
| c2 = splitColor(color2), | |
| res = []; | |
| let index = 0; | |
| while (index !== c1.length) { | |
| res.push(average(c1[index], c2[index])); | |
| index++; |
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() { | |
| 'use strict'; | |
| function flattenES6(arr) { | |
| return arr.reduce(function (flatten, toFlatten) { | |
| return flatten.concat(Array.isArray(toFlatten) ? flattenES6(toFlatten) : toFlatten); | |
| }, []); | |
| } | |
| function flattenES5(arr) { |