Filtering objects by age
JavaScript
Easy
objects
Task «Filtering objects by age»
Write a program that receives a string with objects in JSON format as input. Each object contains the fields "name" (string) and "age" (number). It is necessary to filter the array of objects, keeping only those whose age is greater than 18, and output the names of these objects separated by commas in alphabetical order. If no object matches, output "none".
Input Format
A string in JSON format containing an array of objects with fields name and age.
Output Format
A string of names separated by commas in alphabetical order or "none".
Examples
Example 1
INPUT
[{"name":"Alice","age":25},{"name":"Bob","age":17},{"name":"Charlie","age":30}]
OUTPUT
Alice,Charlie
Example 2
INPUT
[{"name":"David","age":16},{"name":"Eve","age":18}]
OUTPUT
none
Example 3
INPUT
3 2 5
1 2 10 0
2 3 20 0
OUTPUT
none
Example 4
INPUT
3 3 10
1 2 5 1
3 10
2 3 5 0
1 3 100 0
OUTPUT
none
main.js