title: Using string.replace() to alter an URL
body: <p>I have an input text box on a web page that asks for the  name of a city, and a submit button right beside it. In my JavaScript file I have a variable var = url that holds the http address for getting data from openweathermap. I would like to use string.replace(currentCity, inputTextCity) to alter the existing city in that url. Is this the right approach or is there an easier way? Would it be easier to do this with JQuery? Any help would be appreciated! My CodePen link is <a href="http://codepen.io/RDaniels34/pen/zreZwy" rel="nofollow">http://codepen.io/RDaniels34/pen/zreZwy</a>
  my JavaScript for the page is</p>
  
  <pre><code>$(document).ready(function() {
   var url = "http://api.openweathermap.org/data/2.5/weather?q=" + 'Las Cruces' + ",us&amp;units=imperial&amp;APPID=421da4492f2bbe838d519b0e92139dfd"; 
  
    $.getJSON(url, function(json) {
  
      var city = json.name;
      var wind = json.wind.speed;
      var temperature = json.main.temp;
      var weather = json.weather[0].main;
      $(".temp").html(temperature.toFixed(1) + " °F");
      $(".city").html(city);
      $(".wind").html("Wind " + wind + " mph");
      $(".weather").html(weather);
      switch (weather) {
        case "Rain":
          $("#icon").addClass("wi-rain");
          break;
        case "Thunderstorm":
          $("#icon").addClass("wi-thunderstorm");
          break;
        case "Drizzle":
          $("#icon").addClass("wi-raindrops");
          break;
        case "Snow":
          $("#icon").addClass("wi-snow");
          break;
        case "Atmosphere":
          $("#icon").addClass("wi-dust");
          break;
        case "Clear":
          $("#icon").addClass("wi-day-sunny");
          break;
        case "Clouds":
          $("#icon").addClass("wi-cloudy");
          break;
        default:
          break;
      }
  
     function getUrl(city){
        url.replace('Las Cruces', city);
     }
   });
  });
  </code></pre>