Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Write a Dart function that takes a map of products and their stock quantities, and returns a list of products that are out of stock.*/
- void main() {
- Map<String, int> stock = {'apple': 10, 'banana': 0, 'orange': 8, 'grape': 0};
- print(checkStock(stock));
- }
- List<String> checkStock(Map<String, int> stock) {
- List<String> emptyStockList = [];
- for (MapEntry<String, int> e in stock.entries) {
- if (e.value == 0) {
- emptyStockList.add(e.key);
- }
- }
- return emptyStockList;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement