Local Weather Feedback

Local Weather Feedback
0

#1

Good morning everyone. I just finished my Local Weather project and was hoping to get some feedback. I’m really looking to refactor the JS if at possible. Thanks everyone.

Link: https://codepen.io/traekwells/pen/vWKjNy


#2

You could get rid of:

  function convertToCelsius() {
    temperature.innerHTML = celsius;
  }
  function convertToFahrenheit() {
    temperature.innerHTML = fahrenheit;
  }

and replace with one function:

  function convertTo(unit) {
    temperature.innerHTML = unit;
  }

if you change your event listeners to:

  toCelsius.addEventListener("click", function() { convertTo(celsius) });
  toFahrenheit.addEventListener("click", function() { convertTo(fahrenheit) });

#3

Makes perfect sense. Thanks for the feedback! Appreciate it.