Created
January 10, 2021 14:00
-
-
Save sebastianherman/f9c6658aeb856150a41837273aabb51f to your computer and use it in GitHub Desktop.
Intermediate Algorithm Scripting: Missing letters - freeCodeCamp solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fearNotLetter(str) { | |
let letters = str.split(""); | |
let alph = 'abcdefghijklmnopqrstuvwxyz'.split(""); | |
let range = alph.slice(alph.indexOf(letters[0]), alph.indexOf(letters[0])+letters.length+1); | |
console.log("Original range: " + range); | |
for (let i in str) { | |
if (range.includes(str[i])) { | |
range.splice(range.indexOf(str[i]), 1) | |
} | |
} | |
console.log(range); | |
if (range.length > 0) { | |
return range.join(); | |
} else { | |
return undefined; | |
} | |
} | |
fearNotLetter("abcdefghijklmnopqrstuvwxyz") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment