Ad
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');
    • var longestString = (str) => str.split(' ').sort((a, b) => b.length - a.length)[0];
    • 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
    }
    • function getMin(list) {
    • let ret = list.reduce((prev, curr) => {
    • if (curr <= 0) return prev;
    • return (prev <= 0) ? curr : Math.min(curr, prev);
    • }, -1);
    • return ret > 0 ? ret : 0;
    • x = Math.min(...list.filter(i => i > 0));
    • return x !== Infinity ? x : 0
    • }