Skip to content

Instantly share code, notes, and snippets.

@francolaiuppa
Created March 31, 2015 19:37
Show Gist options
  • Save francolaiuppa/5556616ccbc76056cd1d to your computer and use it in GitHub Desktop.
Save francolaiuppa/5556616ccbc76056cd1d to your computer and use it in GitHub Desktop.
hackealo.co solucionador. SPOILER: Aunque pongas la respuesta correcta no funciona
// "acb" es (1*1) + (2*3) + (3*2).
var letters = ['a','b','c','d','e','f','g','h','i','j','k','l',
'm','n','o','p','q','r','s','t','u','v','w','y','x','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','Y','X','Z'];
// var word = 'HZyVYIW'.toLowerCase().split('');
var word = 'HZyVYIW'.split('');
var total = 0;
var msg = '';
word.forEach(function(letter,index){
msg = ((index+1)+' * '+parseInt(letters.indexOf(letter)+1));
console.log(msg);
total += (index+1)*(parseInt(letters.indexOf(letter)+1));
});
console.log(total);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment