title: What is the best way to target an array or a string with user input, and log its respective index?
body: <p>What is the best way to target an array or a string, so that when a user types a letter it finds a match and logs the letter and its index in the array (or the string)?For example  (set-up): </p>
  
  <pre><code>GUESS THIS MOVIE: 
  
  how to train your dragon
  ___ __ _____ ____ ______
  
  Type a letter to guess, you have 10 TRIES:
  User Typed: o
  
  Result: _o_ _o _____ _o__ ____o_
  
  HERES MY CODE: 
      var fs = require('fs');
      var inquirer = require('inquirer');
      var displayProgress = require('./checkGuess');
  
  // var checkGuess = require('./checkGuess');
  
  
  var PlayFunc = function() {
      var blanksArr = [];
      var currentWord = [];
  
  this.getData = function() {
      var stackOv = "";
      fs.readFile("words.txt", "utf8", function(error, data){
          if (error) throw error;
          dataType = data.toLowerCase();
          //data in array
          var wordArr = dataType.split(',');
          //select random from word from data
          var compWord = wordArr[Math.floor(Math.random() * wordArr.length)];//random
          //split chosen word
          currentWord = compWord.split('');
          console.log("========================\n\n\n");
  
          //Looping through the word          
          for (var i = 0; i &lt;= currentWord.length - 1; i++) {
              // pushing blanks 
              var gArr = blanksArr.push("_"); 
  
              //HYPHENS, COLONS, SPACES SHOULD BE PASSED
              stackOv = currentWord.join("").replace(/[^- :'.]/g, "_");
              wordString = currentWord.join("");  
          }   
          console.log("GUESS THIS MOVIE: ");
          fs.writeFile("blanks.txt", stackOv, (err) =&gt; {
              if (err) throw err;
              console.log(wordString);
              fs.readFile('blanks.txt', "utf8",(err, word) =&gt; {
                  if (err) throw err;
                  // console.log("GUESS THIS MOVIE: " + compWord);
                  blanksTxt = word.split(''); //console.log(string.join('').replace(/[^-: '.]/g, "_"));
  
                  displayProgress = new displayProgress();
                  displayProgress.checkGuess(); 
              });
          });         
      });
  }
  
  }
  module.exports = PlayFunc;
  </code></pre>
  
  <p>ON THE NEXT FILE CALLED checkGuess.js I Plan to do the checking (which goes back to my original question (OP).</p>
  
  <pre><code>    var fs = require('fs');
  var inquirer = require('inquirer');
  var PlayFunc = require('./PlayFunc');
  
  var displayProgress = function (){
      // console.log("WORKING CONNECTED CHECKGUESS MODULE");
      // PlayFunc = new PlayFunc();
      // PlayFunc.getData();
  
  
      var a = blanksTxt.join(''); console.log(a); //string a
      var manipulateThisArray = blanksTxt;//reading from blanks.txt
  
      // console.log(manipulateThisArray);
  
  
       this.checkGuess = function(){
           inquirer.prompt([
         {
          type: "input",
          name: "letter",
          message: "Type a letter to guess, you have 10 TRIES:"
         }
  
       ]).then(function(userInput) {
          var correctArray = [];
          // console.log(userInput.letter);
          letterTyped = userInput.letter;
          //logic
          //test if we can parse through the array
          for (var i = 0; i &lt;= manipulateThisArray.length - 1; i++) {
              x = manipulateThisArray[i]; console.log(x);
              // if userinput letter-value matches chosen words letter value 
              // replace this chosen worsa letter with userinput value
              // if(letterTyped == x.charAt(i)) {
  
                  console.log("THERES A MATCH " + x.charAt(i));
              // }else {
                  // console.log("NO MATCH");
              // }
  
          }
       });
  }
  }
  // checkGuess();
  
  module.exports = displayProgress;
  </code></pre>