Swap a list of JSON key with value

You have this

	let player_icon = {
	  boss: "b",
	  earth: ".",
	  enemy: "e",
	  floor: "f",
	  health: "h",
	  player: "p",
	  wall: "w",
	  weapon: "w"

But need this

	let icon_linked_to_player = {
	  .: "earth",
	  b: "boss",
	  e: "enemy",
	  f: "floor",
	  h: "health",
	  p: "player",
	  w: "weapon"

We can write a function to do this. It comes in handy, especially when you have a long list of objects.

	let icon_linked_to_player =
	  Object.keys(player_icon).reduce(function(obj, key) {
	    obj[player_icon[key]] = key;
	    return obj;
	  }, {});