Extract City Facts

Published by Matt in

Create a function that takes an hash as an argument and returns a string with facts about the city. The city facts will need to be extracted from the hashes three properties:

  1. name
  2. population
  3. continent

The string should have the following format: X has a population of Y and is situated in Z (where X is the city name, Y is the population and Z is the continent the city is situated in).

Examples

city_facts({
  name: "Paris",
  population: "2,140,526",
  continent: "Europe"
}) ➞ "Paris has a population of 2,140,526 and is situated in Europe"

city_facts({
  name: "Tokyo",
  population: "13,929,286",
  continent: "Asia"
}) ➞ "Tokyo has a population of 13,929,286 and is situated in Asia"

Notes

Don't add a period at the end.

Watch a quick demo on how Edabit works.