title: How do I grab any segment from URL using Javascript?
body: <p>I have a URL : <code>http://localhost:8080/school/teacher/reports/chapter-quiz/student</code></p>
  
  <p>Getting the last segment, I just need to do this </p>
  
  <p><code>var lastSegment = location.pathname.split('/').pop();</code></p>
  
  <p>But how do I grab the one next to the last one ? <strong>chapter-quiz</strong></p>