From 23f31891a9902e27522934540dbd79ac217b7a42 Mon Sep 17 00:00:00 2001 From: ardaninsaturnu Date: Fri, 22 Apr 2022 10:59:34 +0300 Subject: [PATCH] pushing some code snippets --- 01_Day_JavaScript_Refresher/object/object.js | 97 +++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/01_Day_JavaScript_Refresher/object/object.js b/01_Day_JavaScript_Refresher/object/object.js index ef28c81..b72e94a 100644 --- a/01_Day_JavaScript_Refresher/object/object.js +++ b/01_Day_JavaScript_Refresher/object/object.js @@ -15,4 +15,99 @@ dog.GetDogInfo = function(){ return `this dogs name is ${this.name} and it has good ${this.color} color it has ${this.legs} legs.`; } -console.log(dog.GetDogInfo()) \ No newline at end of file +console.log(dog.GetDogInfo()); + +const users = { + Alex: { + email: 'alex@alex.com', + skills: ['HTML', 'CSS', 'JavaScript'], + age: 20, + isLoggedIn: false, + points: 30 + }, + Asab: { + email: 'asab@asab.com', + skills: ['HTML', 'CSS', 'JavaScript', 'Redux', 'MongoDB', 'Express', 'React', 'Node'], + age: 25, + isLoggedIn: false, + points: 50 + }, + Brook: { + email: 'daniel@daniel.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux'], + age: 30, + isLoggedIn: true, + points: 50 + }, + Daniel: { + email: 'daniel@alex.com', + skills: ['HTML', 'CSS', 'JavaScript', 'Python'], + age: 20, + isLoggedIn: false, + points: 40 + }, + John: { + email: 'john@john.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node.js'], + age: 20, + isLoggedIn: true, + points: 50 + }, + Thomas: { + email: 'thomas@thomas.com', + skills: ['HTML', 'CSS', 'JavaScript', 'React'], + age: 20, + isLoggedIn: false, + points: 40 + }, + Paul: { + email: 'paul@paul.com', + skills: ['HTML', 'CSS', 'JavaScript', 'MongoDB', 'Express', 'React', 'Node'], + age: 20, + isLoggedIn: false, + points: 40 + } +} + +const arrUsers = Object.entries(users); +console.log(arrUsers) + +const valUsers = Object.values(users); +console.log(valUsers) + +const assUsers = Object.assign(users); +console.log(assUsers) + +const keyUsers = Object.keys(users); +console.log(keyUsers) + +const rafik = []; + +arrUsers.map( item => { + console.log(item[0]) + const newObj = { + itemName : item[0], + itemValues : item[1] + } + rafik.push(newObj); +}) + +console.log(rafik); + +console.log( rafik.sort( (a,b) => b.itemValues.skills.length - a.itemValues.skills.length)[0].itemName); + +console.log(rafik.find( item => item.itemValues.skills.includes('React'))) + + +// Find the Mern developer +function findMernDev( name,arr ){ + if( arr.indexOf('React') !== -1 && arr.indexOf('Node') !== -1 && arr.indexOf('MongoDB') !== -1 && arr.indexOf('Express') !== -1 ){ + console.log( name ) + } +} + +for( const item of rafik ){ + + findMernDev( item.itemName, item.itemValues.skills ) + +} \ No newline at end of file