putIn
Adds or sets a key-value pair to a map
.
putIn(targetMap, key, value)
#
ParameterstargetMap
:map
where a pair is addedkey
:string
keyvalue
: A value of supported type
#
Returns- No value
#
Example# Initialize a variable to an empty `map` and add key-value pairsproduct = {}putIn(product, 'availability', 30)putIn(product, 'readyToShip', true)putIn(product, 'shipInternationally', false)print(product) # prints {availability: 30, readyToShip: true, shipInternationally: false}
# Set value of a keyproduct = { name: 'iPhone', model: '8', price: 600}putIn(product, 'name', 'mac')putIn(product, 'model', 'pro')putIn(product, 'price', 1200)print(product) # prints {name: mac, model: pro, price: 1200}