Skip to content

Instantly share code, notes, and snippets.

@ronit-mukherjee
Created December 15, 2018 13:21
Show Gist options
  • Save ronit-mukherjee/c3ed8bc47d464ba49107832058d2d4bc to your computer and use it in GitHub Desktop.
Save ronit-mukherjee/c3ed8bc47d464ba49107832058d2d4bc to your computer and use it in GitHub Desktop.
//https://jsfiddle.net/mukherjeeronit/9rxwt0n5/
function main(students){
var namesOfStudent = [];
for(var i=0; i<students.length; i++){
var student = students[i];
if(student.contact_numbers.length > 1 && student.age < 18){
namesOfStudent.push(student.name);
}
}
console.log("List of Names:- ", namesOfStudent);
}
var input = [{
name: "Ajay",
age: 12,
contact_numbers:[
8647896541,
7489651258
]
},
{
name: "Amit",
age: 16,
contact_numbers:[
8647896541
]
},
{
name: "Shikha",
age: 18,
contact_numbers:[
8647896541,
9745896512,
6589784589
]
},
{
name: "Manish",
age: 62,
contact_numbers:[]
}
];
main(input);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment