[Javascript] replaceAll
Min\nSince the leading digit != 0, we set it to0.\n\n- Max\nFind the first digit != 9, then set it to9.\n\nex. 9563 -> 9963\n    8742 -> 9742\n    9999 -> 9999 
- Min\nSince the leading digit != 0, we set it to`0`.\n\n- Max\nFind **the first digit** != 9, then set it to`9`.\n```\nex. 9563 -> 9963\n    8742 -> 9742\n    9999 -> 9999 (can remap to ITSELF)\n```\n\n\n```\nvar minMaxDifference = function(num) {\n    let str=num+"", i=0;\n    while(str[i]==9){i++};\n\n    let max=str.replaceAll(str[i], 9);\n    let min=str.replaceAll(str[0], 0);\n    return max-min;    \n};\n```\n\n\nThanks for your reading and **up-voting** :)\n\n**\u2B50 Check [HERE](https://github.com/Lynn19950915/LeetCode_King) for my full Leetcode Notes ~**
['Math', 'Greedy', 'JavaScript']