Skip to content

Instantly share code, notes, and snippets.

@JugurthaK
Created March 18, 2018 09:28
Show Gist options
  • Save JugurthaK/eea8155f5abc05cc21426f8ef1216b70 to your computer and use it in GitHub Desktop.
Save JugurthaK/eea8155f5abc05cc21426f8ef1216b70 to your computer and use it in GitHub Desktop.
Lire une phrase encodée, peu importe la base
var decode = function (phrase, base){
// On met en binaire si il n'y a pas eu de base spécifiée
if (base === undefined){
base = 2;
}
var phraseEncodee = phrase.split (" ");
var phraseFinale;
for (var i = 0 ; i < phraseEncodee.length; i++){
var char = phraseEncodee[i];
var char = parseInt(char, base);
phraseFinale += String.fromCharCode(char);
}
// J'ai pas eu le courage de finaliser avec une interface graphique :(
console.log(phraseFinale);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment