title: How to know a string starts/ends with specific character in javascript?
body: <pre><code> var file = "{employee}";
   var imgFile = "cancel.json";
  
    if(file starts with '{' and file ends with '}' ){
       alert("invalid");
    }
    if(imgFile ends with '.json'){
      alert("invalid");
    }
  </code></pre>
  
  <ul>
  <li>How to validate the string starting and ending characters using javascript?</li>
  <li>In "file" the string should not start with '{' and should not end with '}'</li>
  <li>In "imgFile " the string should not end with '.json'</li>
  <li>Does match() works or should i use indexOf()</li>
  </ul>