Letter detector code I have created this function where it detects the first letter of the string provided. I was hoping if you guys can take a look, give your opinion about it and help me to improve it.

 //This function takes a string and outputs 
 //its first letter
 function letterDetector(str){
      //Checking if string is an empty string
      if(str === "" || str === undefined) 
      {return ("Please input an argument");}

      var alphabetsArr = "abcdefghijklmnopqrstuvwxyz".split("");
     //making user input to lower case
     var string = str.toLowerCase().replace(/[^0-9a-z]\d+/gi, '');
     var result = alphabetsArr.map(letter =&gt; {
     if( string.charAt(0) === letter ){
        //logging out the letter as upper case
        console.log("Your first name letter is" + " " + letter.toUpperCase());
     }
   });
}
letterDetector("Adam"); //output A
letterDetector("£1%Adam"); //output A
letterDetector(""); or letterDetector(); //output Please input an argument
While this function does what you want, it can be greatly simplified. 



function letterDetector(str) {
  if (!str) { //Handles both undefined and the empty string
    return "Please input an argument"
  }
  // Replace everything that isn't the letter, then get the first letter.
  const firstLetter = str.replace(/[^a-z]/gi, '').charAt(0)
  return "Your first name letter is " + firstLetter.toUpperCase()
}

for (const str of ["Adam", "£1%Adam", "", undefined]) {
  console.log("'" + str + "'", "--&gt;", letterDetector(str))
}




A few things to note about your implementation: 


return is not a function, there is no need to wrap what you are returning with parenthesis (and generally you shouldn't).
Be consistent. Should this function log to the console or return the result? Personally, I prefer returning to avoid side effects, which will help keep your code simpler when working on more complex projects. 
Uncovered edge case: What if I input 123?
Don't use (near) keywords as variable names. string looks very close to String and could easily be mistaken for it.
Though in this case it seems you aren't handling non-ascii characters, it is a good idea to use toLocaleLowerCase() and toLocaleUpperCase() instead of toLowerCase() and toUpperCase() to avoid a multitude of problems with languages other than English. 
Don't define variables you don't use, result is never used and thus can be dropped. 
Since you use arrow functions, you can use const and let instead of var. This is a good switch to make in order to easily avoid any future pain where variables aren't scoped as you expect (especially if you work with other languages like C or Java where everything is block scoped, var is function scoped)