Skip to content

Instantly share code, notes, and snippets.

@r17x
Created July 13, 2021 05:16
Show Gist options
  • Save r17x/0ea2b8f2b50294f920be7b8a4b231ebd to your computer and use it in GitHub Desktop.
Save r17x/0ea2b8f2b50294f920be7b8a4b231ebd to your computer and use it in GitHub Desktop.
HeyTayoo.js
// HEY TAYO HEY TAYO DIA SI FUNGSI NAKAL MELAJU MENGHAJAR
// basic operation {a + b} {a - b} as function
let add = (a, b) => a + b;
let sub = (a, b) => a - b;
// function for add one {a + 1}
let addOne = (b) => add(1, b);
// function for reverse value by length that defined as {a}
// and solve with Math
let reverse = (a, b) => addOne(sub(a, b));
// function for know the maximum value of numbers
let max = (arr) => Math.max.apply(null, arr);
// function for know the minium value of numbers
let min = (arr) => Math.min.apply(null, arr);
// Study Case
// I/O === Eval/Apply
// I => [1, 2, 3, 4, 5]
// O => [5, 4, 3, 2, 1]
let input = [1, 2, 3, 4, 5];
let output = ((input) => {
let _max = max(input);
let reverses = (item) => reverse(_max, item);
return input.map(reverses);
})(input);
console.log({
input,
output,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment