Javascript output not showing

Tell us what’s happening:

Hi guys I’m trying to write code that removes some special characters from any string URL
and then displays the cleaned string via html.
the javascript works but I can’t seem to get the result to show in the browser. pls help!

Your code so far

<!DOCTYPE html>
<html>
    <head>
        
        <title>Clean URLs</title>
    </head>
    <body>
        
       <div id="display-area" >
                
            <textarea placeholder="insert URL here :)" id="myTextarea"></textarea>
            <button class = 'btn btn-default' id="demo"> Cleanup URL</button>

           </div>
    
       <div id ="result1"><p></p></div>
       <div id ="result2"><p></p></div>
      
     
    </body>
</html>
<script>
        var splitstring = [''];
        var finaloutput = ''; var i = 0;
        
      function cleanupurl(urlstring) {
    
         
        //==========================================//
        urlstring = urlstring.replace(/%21/gi, '!'); 
        urlstring = urlstring.replace(/%23/gi, '#');
        urlstring = urlstring.replace(/%24/gi, '$');
        urlstring = urlstring.replace(/%26/gi, '&');
       
        //==========================================//
        splitstring = urlstring.split('http://');
        document.getElementById("result1").innerHTML =  cleanurloutput1();
        //return 
     }
  
  function cleanurloutput1(){
     return splitstring[1];
        }
        
          function cleanurloutput2(){
     return splitstring[2];
        }

        //document.getElementById("result1").innerHTML = cleanurloutput1();
      
        var x = document.getElementById("myTextarea").value;
        cleanupurl(x);
       
   
   
</script>


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5.

Link to the challenge:

You did not include an answer to “Tell us what’s happening”. What have you tried? What isn’t working as expected? What tests are failing? What don’t you understand? What do you understand?

wow, thanks for the response…
the whole point of the code is to have someone put in input and then the input
is then cleaned up and the result is then inserted in “result1” and/or “result2”

so when the page loads and the user types something in “myTextarea” and clicks the button,
cleanup url(x) is supposed to run.

As for the eventhandler for the button, which one could I use to get it to work…
I tried onclick=“cleanupurl(myTextarea.text())”. it didn’t work either…

pls help ;(

Thanks for the response…
but the code is supposed to take out the ‘percentage characters’ in any encoded URL and replace them with their correct special characters… e.g. replace ‘%21’ with ‘!’

it provides a text area where a user can paste their url, click the button and then have the program ‘clean it up’

so far, nothing happens… how do I fix it ?

it works!!!37 AM
Thanks sooo much!
got rid of. cleanurloutput1() and used a loop to display all elements
in the array as shown below:

while(i < splitstring.length){
        document.getElementById("result1").innerHTML +=  "<p>" + splitstring[i] ;
        i++;
    }

Thanks a bunch!!!
thanks for the help!