JSFiddle - React, Tailwind, and code Playground

by dunerunner

JavaScript 1.7

class Provider {
	  /** 
	   * Gets the weather for a given city 
	   */
	  static getWeather(city) {
	    return Promise.resolve(`The weather of ${city} is Cloudy`)
	  };
	  /** 
	   * Gets the weather for a given city 
	   */
	  static getLocalCurrency(city) {
	    return Promise.resolve(`The local currency of ${city} is GBP`)
	  };
	  /** 
	   * Given Longtitude and latitude, this function returns a city 
	   */
	  static findCity(long, lat) {
	    return Promise.resolve(`London`)
	  };
	};

	// Question 1
	Provider.findCity(0.1278, 51.5074)
	  .then(result => {
	    console.log(result);
	  });

	// Question 2
	Provider.findCity(0.1278, 51.5074)
	  .then(city => {
	    return Provider.getWeather(city);
	  })
	  .then(weather => {
	    console.log(weather);
	  });
    
  // Question 3
  Provider.findCity(0.1278, 51.5074)
	  .then(city => {
	    return Promise.all([Provider.getWeather(city), Provider.getLocalCurrency(city)]);
	  })
    .then(values => {
			values.forEach(val => console.log(val));
    });