Tell us what’s happening:
How to return key of Object when the value is known, Please have a look at the comment i made inside my code.
Your code so far
function fearNotLetter(str) {
//make a obj
let alphabetObj={
a:1,
b:2,
c:3,
d:4,
e:5,
f:6,
g:7,
h:8,
i:9,
j:10,
k:11,
l:12,
m:13,
n:14,
o:15,
p:16,
q:17,
r:18,
s:19,
t:20,
u:21,
v:22,
w:23,
x:24,
y:25,
z:26
}
let checkIsFullRange = alphabetObj[str.charAt(str.length-1)]-alphabetObj[str.charAt(0)]+1;
if(str.length===checkIsFullRange){
return undefined;
}else{
for(let i=0;i<str.length;i++){
if(alphabetObj[str[i]]-alphabetObj[str[i+1]]===-2){
//For test case abce at i=2 this condition will become true.Here I want to return KEY of missing aplhabet i.e d and it's value is four. How to do it ?
}
}
}
}
let alphabetObj={
a:1,
b:2,
c:3}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
.
Challenge: Missing letters
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters