Rounding in Millions

Published by Joshua Señoron in

Given a list of cities and populations, return a list where all populations are rounded to the nearest million.

Examples

millions_rounding([
  ["Nice", 942208],
  ["Abu Dhabi", 1482816],
  ["Naples", 2186853],
  ["Vatican City", 572]
])
[
  ["Nice", 1000000],
  ["Abu Dhabi", 1000000],
  ["Naples", 2000000],
  ["Vatican City", 0]
]

Notes

Round down to 0 if a population is below 500,000.

Watch a quick demo on how Edabit works.