class Functionator
  def initialize(s)
    s.split(' ').each { | i | define_singleton_method :"#{i}" do Functionator.new(s.split(' ')[1..-1].join(' ')) end }
  end
end

def functionator(string)
  Functionator.new(string)
end
Code
Diff
  • var longestString = (str) => require('lodash')(str.split(' ')).maxBy('length');
  • 1
    var longestString = (str) => str.split(' ').sort((a, b) => b.length - a.length)[0];
    
    1+
    var longestString = (str) => require('lodash')(str.split(' ')).maxBy('length');
    
Code
Diff
  • function getMin(list) {
      x = Math.min(...list.filter(i => i > 0));
      return x !== Infinity ? x : 0
    }
  • 11
    function getMin(list) {
    
    2
        let ret = list.reduce((prev, curr) => {
    
    3
            if (curr <= 0) return prev;
    
    4
            return (prev <= 0) ? curr : Math.min(curr, prev);
    
    5
        }, -1);
    
    6
        return ret > 0 ? ret : 0;
    
    2+
      x = Math.min(...list.filter(i => i > 0));
    
    3+
      return x !== Infinity ? x : 0
    
    77
    }