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
| // Requires Mustache and jQuery | |
| window.component = (function () { | |
| var collection = {}; | |
| return function (arg) { | |
| switch (typeof arg) { | |
| case "string": | |
| return collection[arg] || null; | |
| case "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
| /* | |
| The range function must take a start integer and end integer | |
| and generate an array of the consecutive integers between them (inclusively). | |
| Example 1: range(1, 5) == [1, 2, 3, 4, 5]; | |
| Example 2: range(2, -2) == [2, 1, 0, -1, -2]; | |
| Example 3: range(4, 4) == [4]; | |
| */ | |
| // Method #1: an imperative approach with a loop and mutation | |
| function range(start, 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
| const range = (start, end) => { | |
| switch (true) { | |
| case start > end: return range(end, start).reverse(); | |
| default: return Array.from({ length: end - start + 1 }, (_, index) => start + index); | |
| } | |
| }; | |
| const toFizzBuzz = (number) => { | |
| const isFizz = number % 3 == 0; | |
| const isBuzz = number % 5 == 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
| using Newtonsoft.Json; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| namespace Experimentation | |
| { | |
| public static class Extensions | |
| { | |
| #region IEnumerable Extensions |
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
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin porttitor scelerisque lacus, ornare fermentum odio bibendum ac. Duis eget vulputate elit, dignissim tincidunt eros. In pretium dictum ipsum, et tempor velit. Aliquam tincidunt purus augue, placerat egestas neque iaculis quis. Aliquam a diam rhoncus neque semper accumsan. Morbi laoreet non mi auctor tristique. Praesent tincidunt, dolor ac posuere consectetur, enim enim viverra eros, eu dictum libero est eu massa. Vestibulum congue metus non erat sagittis varius. Nam consequat dui enim. Mauris augue eros, ultricies vitae eleifend et, mollis ultricies neque. Quisque elementum ante et est scelerisque, at condimentum ipsum ornare. |
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 eventManager(){ | |
| var set = {}; | |
| return function(e){ | |
| return { | |
| listen(cb) { | |
| if (typeof e !== "string" || typeof cb !== "function") return this; | |
| set[e] = (set[e] || []).concat(cb); | |
| return this; | |
| }, | |
| emit(data) { |
NewerOlder