Missing letters Intermediate Algorithms

I dont understand why 3rd case doesnt work. I think it’s a bug with slice, but im not sure;

function fearNotLetter(str) {
  let abecedario = 'abcdefghijklmnopqrstuvwxyz';
  
  let start = abecedario.indexOf(str[0])
  let finish = abecedario.indexOf(str[str.length-1])
  abecedario = abecedario.slice(start,((finish-start)+1))
  for (let i = 0; i < abecedario.length; i++){
    if (str.indexOf(abecedario[i]) == -1){
      return abecedario[i]
    }
  }
  return undefined;
}

fearNotLetter("stvwx");

slice gives an empty string if i use the 2nd argument with any number, only in this case

I would brush up on the slice documentation to make sure you are using it properly. Pay special attention to what the second parameter is.

2 Likes

Thanks bud, i had it wrong

I get it confused with splice all the time as well :slight_smile:

1 Like