Probably the most used way of iterationg through arrays so far:
const names = ["carlos", "ana", "alex"];
for(let i = 0; i < names.length; i++){allowedToDrink will be the list of people who are older than 21.const allowedToDrink = people.filter(person =>{
return person.age >= 21;
});
// in one line:
// const allowedToDrink = people.filter(person => person.age >= 21);
console.log(allowedToDrink);
// [ { name: 'Candice', age: 25 },const capsMs = cities1.filter(theCity => theCity[0] === "m")
.map(city => {
if (city.includes(" ")){
let splitted = city.split(" ");
const len = splitted.length;
for (let i = 0; i < len; i++){
splitted[i] = splitted[i][0].toUpperCase() + splitted[i].slice(1);
}
return splitted.join(" ");const newArray = numbers.filter(number =>{
return ((number % 2 ===1)&&(number<100))
});
console.log(newArray); // [ 1, 99, 73 ].reverse() on itWe will be working on the following array:
Search text through all files at once
Command + Shift + fCtrl + Shift + fRe-open a closed editor When you have multiple open files and accidentally close one or more of them, finding them, and re-opening can be time-consuming and a little frustrating. This is an undo feature exclusively for tabs:
Mac: Command + Shift + t
| // Example: | |
| // User has an array of references to posts | |
| // Posts have an array of references to comments | |
| // Or Dani's example: https://github.com/webmad-shared/doublepopulate/blob/master/bin/seeds.js | |
| router.get('/posts', (req, res, next) => { | |
| Model.find() | |
| .populate('oneProperty') // .populate("creator") | |
| .populate({ |
| // example with Alina Z. | |
| Act.find() | |
| .then(allSuggestedActs => { | |
| const user = new User({ | |
| fullName, | |
| email, | |
| encryptedPassword, | |
| score: 0, |
| const product = { | |
| name: "AmazonBasics Apple Certified Lightning to USB Cable", | |
| price: 7.99, | |
| manufacter: "Amazon", | |
| reviews: | |
| [ | |
| { user: "Pavel Nedved", | |
| comments: "It was really usefull, strongly recommended", | |
| rate: 4 | |
| }, |