Avatar of gudii9
Flag for United States of America

asked on 

mapBully challenge


 I am working on below challenge

[/Map-1 > mapBully
prev  |  next  |  chance

Modify and return the given map as follows: if the key "a" has a value, set the key "b" to have that value, and set the key "a" to have the value "". Basically "b" is a bully, taking the value and replacing it with the empty string.

mapBully({"b": "dirt", "a": "candy"}) → {"b": "candy", "a": ""}
mapBully({"a": "candy"}) → {"b": "candy", "a": ""}
mapBully({"b": "carrot", "c": "meh", "a": "candy"}) → {"b": "candy", "c": "meh", "a": ""}

how below got below result

mapBully({"a": "candy"}) → {"b": "candy", "a": ""}

there is no b in the input map right then how it came in the output map?
JavaProgramming Languages-OtherJava EESystem ProgrammingProgramming

Avatar of undefined
Last Comment

8/22/2022 - Mon