Javascript and C++ solutions
Javascript: using toString().split(\'\') to create the Array to reduce\n\nvar subtractProductAndSum = n => \n    n.toString().split(\'\').map(Number).reduce((a,
*Javascript: using toString().split(\'\') to create the Array to reduce*\n```\nvar subtractProductAndSum = n => \n    n.toString().split(\'\').map(Number).reduce((a, b) => a * b) -\n    n.toString().split(\'\').map(Number).reduce((a, b) => a + b);\n```\n\n*Javascript: using Array.from() to create the Array to reduce*\n```\nvar subtractProductAndSum = n =>\n    Array.from(String(n), Number).reduce((a, b) => a * b) -\n    Array.from(String(n), Number).reduce((a, b) => a + b);\n```\n\n*C++: the old-fashioned way*\n```\nclass Solution {\npublic:\n    int subtractProductAndSum(int n, int p = 1, int s = 0) {\n        while (n)\n            p *= n % 10,\n            s += n % 10,\n            n /= 10;\n        return p - s;\n    }\n};\n```
[]