Created
December 15, 2018 13:52
-
-
Save ronit-mukherjee/8befdbb9aafa0c096946b5a736b9d30d to your computer and use it in GitHub Desktop.
Solution of Program on http://ronitmukherjee.com/practice-javascript-programs-for-interview/#RMJPQ8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main(input) { | |
var nameOfUsers = []; | |
var visitsTotal = 0; | |
for (var i = 0; i < input.length; i++) { | |
var user = input[i]; | |
visitsTotal = visitsTotal + user.total_visit_count; | |
if (user.total_visit_count > 5) { | |
nameOfUsers.push(user.name); | |
} | |
} | |
console.log('List of Names:-', nameOfUsers); | |
console.log('Total Website Visits Count:' + visitsTotal); | |
} | |
var input = [{ | |
name: "Ronit", | |
total_visit_count: 4 | |
}, | |
{ | |
name: "Sumit", | |
total_visit_count: 15 | |
}, | |
{ | |
name: "Amit", | |
total_visit_count: 5 | |
}, | |
{ | |
name: "Surbhi", | |
total_visit_count: 10 | |
} | |
]; | |
main(input); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment