Skip to content

Instantly share code, notes, and snippets.

View JaoodxD's full-sized avatar
🙂

Maksym Shenderuk JaoodxD

🙂
View GitHub Profile
@JaoodxD
JaoodxD / 1-slow.js
Last active October 20, 2023 20:13
Perf diff
'use strict'
var arr = new Array(100).fill(0).map((e, i) => i)
var res = 0
function myFor (arr) {
var tempSum = 0
for (let j = 0; j < 10_000_000; j++) {
for (let index = 0; index < arr.length; index++) {
tempSum += arr[index]
}
@JaoodxD
JaoodxD / 1.js
Last active October 20, 2023 17:48
15x perf difference
var arr = new Array(100).fill(0).map((e, i) => i);
var res = 0
function myFor(arr) {
for (let j = 0; j < 10_000_000; j++) {
for (let index = 0; index < arr.length; index++) {
res += arr[index];
}
}
}
@JaoodxD
JaoodxD / millipede-of-words.js
Last active December 28, 2022 19:00
millipede of words kata solution
'use strict';
// find first letter of the word
const getFirstLetter = (word = '') => word[0];
// find last letter of the word
const getLastLetter = (word = '') => word[word.length - 1];
// test whether last letter of first word equal to first letter of second word
const testWords = (word1, word2) => getLastLetter(word1) === getFirstLetter(word2);
// test whether array is valid chain of millipede words
const testArray = (array) => {
@JaoodxD
JaoodxD / helloworld.js
Last active April 30, 2023 09:27
Lagrange polynomial 'hello world!'
const greet = () => {
const L = (x) => -
( 1699 / 831600 * x ** 11) +
( 37339 / 302400 * x ** 10) -
( 589129 / 181440 * x ** 9) +
( 1965121 / 40320 * x ** 8) -
( 17402561 / 37800 * x ** 7) +
( 20479411 / 7200 * x ** 6) -
( 233153797 / 20160 * x ** 5) +
( 3667222847 / 120960 * x ** 4) -