Things go wrong. Files don't exist. JSON is malformed. APIs return garbage. Good code anticipates failure and handles it cleanly — without crashing everything.
Write a function parseAndDouble(input) that:
input as a JSON numberYour program receives comma-separated inputs. For each, call parseAndDouble and print the result.
Input: 5,abc,3.5,null,10
Output: 10
-1
7
-1
20
null, strings, booleans, and invalid JSON all count as failures (return -1).