Coerce and Sum (Ignore NaN)

JavaScript Medium 7 views
Back to Questions

Problem Description

You get a JSON array. Convert every item with Number(x). Ignore items that become NaN. Sum remaining values and print the sum.

Input Format

One line JSON array.

Output Format

One number output.

Sample Test Case

Input:
["10","abc",true,null,5]
Output:
16

Constraints

Array length up to 2e5.

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next