Skip to content

Instantly share code, notes, and snippets.

@jeremymouzin
Created July 3, 2020 11:59
Show Gist options
  • Select an option

  • Save jeremymouzin/85a7283f844f9436553c1879037321f4 to your computer and use it in GitHub Desktop.

Select an option

Save jeremymouzin/85a7283f844f9436553c1879037321f4 to your computer and use it in GitHub Desktop.
Challenge 9 du Challenge JavaScript 10 jours de Scrimba
// 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