Rounding In Millions

Published by Deep Xavier in

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

Examples

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

millionsRounding([
  ["Manila", 13923452],
  ["Kuala Lumpur", 7996830],
  ["Jakarta", 10770487]
]) ➞ [
  ["Manila", 14000000],
  ["Kuala Lumpur", 8000000],
  ["Jakarta", 11000000]
]

Notes

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

Watch a quick demo on how Edabit works.