Skip to main content

Posts

Showing posts with the label JavaScript for-loop

JavaScript for-loop, forEach, Map, Filter and Sort Functions | forEach() .map(), .filter() .sort()

//Exploring for-loop, forEach, Map, Filter & Sort Functions //Write the code to get the array of names from the given array of users //pick only active users //sort users by age ascending Result URL link:  https://playcode.io/1943698 When you loop through (or iterate through) an array, the first thing you think of is probably a for loop,   .forEach() , .map(), and .filter() are all just other ways of iterating through arrays to perform a specific task on each array element and are called methods. //Exploring for-loop, forEach, Map, Filter & Sort Functions //Write the code to get the array of names from the given array of users //pick only active users //sort users by age ascending var users = [   { id : 1 , name : 'Anil' , isActive : true , city : 'Noida' , age : 39 },   { id : 2 , name : 'Alok' , isActive : true , city : 'GR Noida' , age : 40 },   { id : 3 , name : 'Sunil' , isActive : false , city : 'Delhi' , age : 29 },   { ...