I implement a function that accepts a string and returns the position of each character in this string.
Function:
alphabet_position("The sunset sets at twelve o' clock.") Must return:
"20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11" It is impossible to implement, my algorithm produces an error -1. What algorithm to invent to implement, I will not apply mind.
function alphabetPosition(allLetters, letter) { return allLetters.indexOf(letter); } var alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]; var letter = "The sunset sets at twelve o' clock" var letterPosition = alphabetPosition(alphabet, letter);