title: javascript alert is not returning any value
body: <p>I have a particular function that should execute only after I click OK in the alert box
  my code is like this.I dont know whether there is 'dialogueresult'in javascript,like that in c#</p>
  
  <pre><code>    function showCreds() {
         var y='';
         var result=UpdateCredentials();
         if(result=='1'){y = alert('Creds updated successfully');}
         if(y==true){
           clearFields();
         }
      }
  </code></pre>
  
  <p>Is there any possible way to do this.I also did a test code for this</p>
  
  <pre><code>function myfun() {
      var y = alert('test');
      alert(y);
  }
  </code></pre>
  
  <p>but the second alert is showing undefined,and if</p>
  
  <pre><code>alert(y);
  </code></pre>
  
  <p>is replaced with </p>
  
  <pre><code>alert(y.toString()) 
  </code></pre>
  
  <p>nothing is displaying
  also have to work with alert, neither confirm nor prompt</p>