'Using Promise.all to create map
I have the following list = ["yellow", "blue", "red"]
I want to create a map, while with await and promiseAll while using the entries as the map key, and the function result as the value.
e.g:
async function concatStr(color): Promise<String> {
return color + "dosomthing"
}
and the map will be:
{
"yellow": "yellowdosomething",
"blue": "bluedosomething",
"red": "reddosomething"
}
I believe that I need to use yield , but not sure how to do it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|