Return the Objects Keys and Values

Published by kochug in

Create a method that takes a Map<String, String> and return the values as a separate array. Return the keys sorted alphabetically, and their corresponding values in the same order.

Examples

getValues({ "a": "1", "b": "2", "c": "3" } )
➞ ["1", "2", "3"]

getValues({ "a": "Apple", "b": "Microsoft", "c": "Google" })
➞ ["Apple", "Microsoft", "Google"]

getValues({ "key1": "true", "key2": "false", "key3": "undefined" })
➞ ["true", "false", "undefined"]

Notes

Remember to sort the keys.

Watch a quick demo on how Edabit works.