title: Javascript remove extra underscores at the end of a string only
body: <p>I have a requirement to remove extra underscores from a string. The condition is if they occur at the very end of the string only. </p>
  
  <p>As an example, we have DELL_  and DELL__  that needs to be changed to DELL.</p>
  
  <p>I was considering using str.replace but I need to match cases specifically if it occurs at the end of the string and not all occurrences in that string. Also, I only want to run this script IF it detects the extra underscores.</p>
  
  <p>I need to have some logic such as IF ( hasExtraUnderscores ) { remove extra underscores }</p>
  
  <p>How can I do this in javascript?</p>
  
  <p>NOTE: We are unable to use JQuery and need to do this in native javascript if possible.</p>