Layout: Title: “Missing letter” Date: 2017-11-13 12:24 Categories: —
Missing letter
I was doing an exercise on freecodecamp about missing letters it was an interesting exercise and all thanks to the helpful links which made me understand and how to solve the problem I was given to solve.
Problem
You will create a program that will find the missing letter from a string and return it. If there is no missing letter, the program should return undefined. There is currently no test case for the string missing more than one letter, but if there was one, recursion would be used. Also, the letters are always provided in order so there is no need to sort them.
Solution
The code of current character, will iterate through to check the available character, I assigned a new variable called letter to get the first index.
if code of current character is not equal to first character plus number of iteration hence character has been escaped if current character has escaped one character find previous char and return undefined.
Experience
I wouldn’t say it was an easy exercise nor hard but with the help of helpful links they provided it was understandable and approacheble. It helped on reminding me the difference between charCodeAt and fromCharCode.