Read a JSON array where each element is {"ok": boolean, "value": number}. Treat each as a promise that fulfills with value (ok=true) or rejects with value (ok=false). Using Promise.allSettled semantics, print two lines: the sum of fulfilled values, then the count of rejections.
Input: one JSON array. Output: two lines.
Your program reads from stdin and prints to stdout.
Example 1
Input: [{"ok":true,"value":5},{"ok":false,"value":9},{"ok":true,"value":1}]
Output: 6 1
Hints
Read a JSON array where each element is {"ok": boolean, "value": number}. Treat each as a promise that fulfills with value (ok=true) or rejects with value (ok=false). Using Promise.allSettled semantics, print two lines: the sum of fulfilled values, then the count of rejections.
Input: one JSON array. Output: two lines.
Your program reads from stdin and prints to stdout.
Example 1
Input: [{"ok":true,"value":5},{"ok":false,"value":9},{"ok":true,"value":1}]
Output: 6 1
Hints