Created
February 26, 2024 14:01
-
-
Save rozanovz/2b19bde7300fedf962d68cafadc9e028 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const removeDigit = (digit, remove) => { | |
| let newDigit = `${digit}`; | |
| if(newDigit.indexOf(remove) === -1) return digit; | |
| let indexes = []; | |
| for (let i = 0; i < newDigit.length; i++){ | |
| if(newDigit[i] == remove) indexes.push(i); | |
| } | |
| return Math.max(...indexes.map((i) => { | |
| return `${newDigit.substring(0, i)}${newDigit.substring(i+1)}` | |
| })); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment