Skip to content

Instantly share code, notes, and snippets.

View moonwave99's full-sized avatar

Diego Caponera moonwave99

View GitHub Profile

Shortcuts

Text shortcuts

symbol name effect
⌘+c cmd + c copy selected text
⌘+v cmd + v paste selected text
⌘+x cmd + x cut selected text
⌘+a cmd + a select all text

Function Exercises

Max of an array

Write a function that accepts an array of number, and returns the greatest of them:

function max(numbers) {
    // find a strategy to determine the biggest entry of the array
 // hints:
@moonwave99
moonwave99 / function_exercise.md
Created March 30, 2023 09:54
Function exercise

Understanding instructions

Given the following task:

Write a function named max that accepts two numbers as parameters, and returns the greater of the two.

Let's parse this sentence as a programmer:

  • write a function;
  • the function should be named max;
export function mosconize(s) {
return s.replace('.', '').toLowerCase();
}
export function findMona(monas) {
return monas.filter(m => m.slamsDoor && m.closesShouting);
}
export function nervousBreak(arr) {
const x = arr.find(({ madeMeNervous }) => madeMeNervous);
@moonwave99
moonwave99 / kuler_palette.js
Last active August 29, 2015 14:16
Get a space separated list of an Adobe Color [formerly known as Kuler] palette.
// paste in your browser's devtools and run:
$('[data-comp="hex"]').map(function(){return '#' + this.value}).toArray().join(' ');
// raw js:
Array.prototype.map.call(document.querySelectorAll('[data-comp="hex"]'), function(item){ return "#" + item.value}).join(' ');