├── LICENSE ├── README.md └── app.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Nika Shamiladze 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # point-filter 2 | point filter with native js 3 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | let data = [{ 2 | firstName: "Nika", 3 | lastName: "Shamiladze", 4 | points: [{ 5 | point: "11", 6 | verified: false, 7 | date: "06/06/2021" 8 | }, 9 | { 10 | point: "12", 11 | verified: false, 12 | date: "08/11/2021" 13 | }, 14 | { 15 | point: "77", 16 | verified: true, 17 | date: "01/02/2021" 18 | }, 19 | { 20 | point: [{ 21 | point: "70", 22 | verified: true, 23 | date: "07/08/2021" 24 | }, 25 | { 26 | point: "88", 27 | verified: true, 28 | date: "01/05/2021" 29 | }], 30 | verified: true, 31 | date: "07/09/2021" 32 | }] 33 | }]; 34 | 35 | let user = []; 36 | 37 | data.map((item) => { 38 | item.points.map((point) => { 39 | if (point.date.length > 0 || point.date.length) { 40 | if (typeof point.point === "object") { 41 | point.point.map((x) => { 42 | if (x.date.length > 0 || x.date) { 43 | if (x.verified) { 44 | if (+x.point > 0 && +x.point > 10) { 45 | const getFullYear = point.date.split("/")[2]; 46 | const getLocalYear = new Date().getFullYear(); 47 | if (+getFullYear === getLocalYear) { 48 | console.log('array'); 49 | user.push({ 50 | firstName: item.firstName, 51 | lastName: item.lastName, 52 | fullName: item.firstName + " " + item.lastName, 53 | points: [point.point] 54 | }) 55 | console.log(user); 56 | } 57 | } 58 | } 59 | } 60 | }) 61 | } else { 62 | if (point.verified) { 63 | if (+point.point > 0 && +point.point > 10) { 64 | const getFullYear = point.date.split("/")[2]; 65 | const getLocalYear = new Date().getFullYear(); 66 | if (+getFullYear === getLocalYear) { 67 | console.log('collection'); 68 | user.push({ 69 | firstName: item.firstName, 70 | lastName: item.lastName, 71 | fullName: item.firstName + " " + item.lastName, 72 | points: [point.point] 73 | }) 74 | console.log(user); 75 | } 76 | } 77 | } 78 | } 79 | } 80 | }) 81 | }) 82 | --------------------------------------------------------------------------------