Skip to content
Snippets Groups Projects
standaloneFunctions.md 961 B
Newer Older
  • Learn to ignore specific revisions
  • Arkerthan's avatar
    Arkerthan committed
    # Standalone JS Functions
    
    Collection of custom functions without dependencies on FC specific variables/data structures.
    
    ## utilJS.js
    
    
    bcy603's avatar
    bcy603 committed
    * `arraySwap(array, a , b)`:
    
    Arkerthan's avatar
    Arkerthan committed
        Swaps two values in an array.
    
    
    bcy603's avatar
    bcy603 committed
    * `capFirstChar(string)`:
    
    Arkerthan's avatar
    Arkerthan committed
        Capitalizes the first character of `string`.
    
    * `addA(word)`:
        Adds an `an ` if the first character is a vocal, otherwise `a `.
    
    
    bcy603's avatar
    bcy603 committed
    * `ordinalSuffix(i)`:
    
    Arkerthan's avatar
    Arkerthan committed
        Takes a number and appends the appropriate suffix.
        Example: `ordinalSuffix(1)` gives `1st`.
    
    
    bcy603's avatar
    bcy603 committed
    * `ordinalSuffixWords(i)`:
    
    Arkerthan's avatar
    Arkerthan committed
        Takes a number and returns the appropriate ordinal.
    
    bcy603's avatar
    bcy603 committed
        Example: `ordinalSuffix(1)` gives `first`.
        For number greater than 19 identical to `ordinalSuffix(i)`
    
    * `removeDuplicates(array)`:
    
    Arkerthan's avatar
    Arkerthan committed
        Takes an array and returns a new array without duplicate entries.
    
    
    bcy603's avatar
    bcy603 committed
    * `jsDef(x)`:
    
    lowercasedonkey's avatar
    lowercasedonkey committed
        Returns whether x is undefined. A JS port of SugarCube's def.
    
    Arkerthan's avatar
    Arkerthan committed
    
    
    bcy603's avatar
    bcy603 committed
    * `between(a, low, high)`:
    
    Arkerthan's avatar
    Arkerthan committed
        Returns `true` if `a` is between `low` and `high`, otherwise `false`.