Created
July 3, 2020 11:59
-
-
Save jeremymouzin/85a7283f844f9436553c1879037321f4 to your computer and use it in GitHub Desktop.
Challenge 9 du Challenge JavaScript 10 jours de Scrimba
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
| // Version lisible pour les débutants | |
| function largestNumber(num) { | |
| // On concatène plusieurs 9 côte à côte | |
| const nombreChaine = '9'.repeat(num); | |
| // On convertit la chaîne en un nombre | |
| return Number(nombreChaine); | |
| } | |
| // Version compacte de la solution précédente | |
| function largestNumber(num) { | |
| return +'9'.repeat(num); | |
| } | |
| // Version "mathématique", on soustrait 1 à 10 puissance num | |
| function largestNumber(num) { | |
| return 10 ** num - 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment