layout: post «««< HEAD title: “Missing leters” ======= title: Missing leters
727f0d1b7808a08bf15748d4f7bba79bf504005c date: 2017-11-08 —
Missing letters
«««< HEAD
=======
727f0d1b7808a08bf15748d4f7bba79bf504005c This exercise was the most challenging one and i spent much time on it , trying to figure out how am i going to solve it and it made me to thin more and come up with another ideas.
Instructions:
Find the missing letter in the passed leteer range and return it
My Approach
In the given function i decided to the create a variable called first which is equal to string.chartCodeAt index zero, I diid that to compare it to the charactercode at the same position. On my test statement i said if string.charCodeAt(i) is not equal to first index meaning that the missing letter is is the one next in the sequence and equal to first . Then it returned the correct letter using str.fromCharCode(first). If there are the same , the expected letter in the corrrect position and all it need to do is to increase first by 1.
Problem started:
when it was not returning the missing letter, like it was returning the whole array and i kept on trying and by checking my if statement, like if the test statement is wrong then it wiil return wrong result.
«««< HEAD
=======
727f0d1b7808a08bf15748d4f7bba79bf504005c I decided to use difference method so that i get the correct result. I enjoyed it even though i it was challenging and am execited because because at last it returned the missing letter.