title: Alternative to the lastIndexOf() function
body: <p>Here is the task at hand:</p>
  <blockquote>
  <p>&quot;Write a function called <code>stringLastIndexOf</code>, which accepts two strings: the first is a word and the second is a single character.</p>
  <p>The function should return the last index at which the character exists or -1 if the character is not found.</p>
  <p>Do not use the built in <code>String.lastIndexOf()</code> function!&quot;</p>
  </blockquote>
  <p>I specifically am struggling with the end requirement, which is to get my function to return the exact position of where the str2 character exists. What could I do to work around not using the <code>lastindexof</code> function to do this?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function stringLastIndexOf(str1, str2) {
    var pos = str1.includes(str2, -1);
    if (pos !== true) {
      return -1;
    } else {
      return str2.position();
    }
  }
  console.log(
    stringLastIndexOf('word', 'w'),
    stringLastIndexOf('pumped', 'f')
    );
    </code></pre>
  </div>
  </div>
  </p>