├── .gitignore ├── .prettierrc ├── README.md ├── assets └── screencapture.png ├── css ├── main.css ├── main.css.map ├── main.min.css └── main.min.css.map ├── index.html ├── index.js └── sass └── main.scss /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # Logs 4 | 5 | logs _.log npm-debug.log_ yarn-debug.log* yarn-error.log* lerna-debug.log\* 6 | 7 | # Diagnostic reports (https://nodejs.org/api/report.html) 8 | 9 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 10 | 11 | # Runtime data 12 | 13 | pids _.pid _.seed \*.pid.lock 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | 21 | coverage \*.lcov 22 | 23 | # nyc test coverage 24 | 25 | .nyc_output 26 | 27 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 28 | 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | 33 | bower_components 34 | 35 | # node-waf configuration 36 | 37 | .lock-wscript 38 | 39 | # Compiled binary addons (https://nodejs.org/api/addons.html) 40 | 41 | build/Release 42 | 43 | # Dependency directories 44 | 45 | node_modules/ jspm_packages/ 46 | 47 | # TypeScript v1 declaration files 48 | 49 | typings/ 50 | 51 | # TypeScript cache 52 | 53 | \*.tsbuildinfo 54 | 55 | # Optional npm cache directory 56 | 57 | .npm 58 | 59 | # Optional eslint cache 60 | 61 | .eslintcache 62 | 63 | # Microbundle cache 64 | 65 | .rpt2_cache/ .rts2_cache_cjs/ .rts2_cache_es/ .rts2_cache_umd/ 66 | 67 | # Optional REPL history 68 | 69 | .node_repl_history 70 | 71 | # Output of 'npm pack' 72 | 73 | \*.tgz 74 | 75 | # Yarn Integrity file 76 | 77 | .yarn-integrity 78 | 79 | # dotenv environment variables file 80 | 81 | .env .env.test 82 | 83 | # parcel-bundler cache (https://parceljs.org/) 84 | 85 | .cache 86 | 87 | # Next.js build output 88 | 89 | .next 90 | 91 | # Nuxt.js build / generate output 92 | 93 | .nuxt dist 94 | 95 | # Gatsby files 96 | 97 | .cache/ 98 | 99 | # Comment in the public line in if your project uses Gatsby and _not_ Next.js 100 | 101 | # https://nextjs.org/blog/next-9-1#public-directory-support 102 | 103 | # public 104 | 105 | # vuepress build output 106 | 107 | .vuepress/dist 108 | 109 | # Serverless directories 110 | 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | 115 | .fusebox/ 116 | 117 | # DynamoDB Local files 118 | 119 | .dynamodb/ 120 | 121 | # TernJS port file 122 | 123 | .tern-port -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "all", 8 | "bracketSpacing": true, 9 | "jsxBracketSameLine": false, 10 | "arrowParens": "avoid", 11 | "proseWrap": "always" 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CODEWARS ⚔️ and other javascript tasks 2 | -------------------------------------------------------------------------------- /assets/screencapture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ViktorSvertoka/codewars/f61882f4d26a6c33fefbe78830a085adeddfa952/assets/screencapture.png -------------------------------------------------------------------------------- /css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Open Sans", sans-serif; 3 | padding: 80px; 4 | } 5 | 6 | .header-wrap { 7 | display: -webkit-box; 8 | display: -ms-flexbox; 9 | display: flex; 10 | -webkit-box-align: center; 11 | -ms-flex-align: center; 12 | align-items: center; 13 | -webkit-box-pack: start; 14 | -ms-flex-pack: start; 15 | justify-content: flex-start; 16 | } 17 | 18 | .list-btn { 19 | list-style: none; 20 | display: -webkit-box; 21 | display: -ms-flexbox; 22 | display: flex; 23 | -webkit-box-orient: horizontal; 24 | -webkit-box-direction: normal; 25 | -ms-flex-direction: row; 26 | flex-direction: row; 27 | gap: 32px; 28 | padding: 0; 29 | margin-bottom: 60px; 30 | border-bottom: 2px solid #e3e3e3; 31 | padding-bottom: 20px; 32 | } 33 | 34 | .btn { 35 | height: 40px; 36 | border-radius: 10px; 37 | color: #ffffff; 38 | background-color: #3498db; 39 | border: none; 40 | padding: 0 20px; 41 | -webkit-box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.08), 0px 2px 2px rgba(0, 0, 0, 0.12); 42 | box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.08), 0px 2px 2px rgba(0, 0, 0, 0.12); 43 | } 44 | 45 | .container { 46 | display: -webkit-box; 47 | display: -ms-flexbox; 48 | display: flex; 49 | -webkit-box-align: center; 50 | -ms-flex-align: center; 51 | align-items: center; 52 | -webkit-box-pack: center; 53 | -ms-flex-pack: center; 54 | justify-content: center; 55 | } 56 | 57 | .wrapper { 58 | -webkit-box-pack: start; 59 | -ms-flex-pack: start; 60 | justify-content: flex-start; 61 | -webkit-box-orient: vertical; 62 | -webkit-box-direction: normal; 63 | -ms-flex-direction: column; 64 | flex-direction: column; 65 | } 66 | 67 | .js-form { 68 | display: -webkit-box; 69 | display: -ms-flexbox; 70 | display: flex; 71 | -webkit-box-orient: vertical; 72 | -webkit-box-direction: normal; 73 | -ms-flex-direction: column; 74 | flex-direction: column; 75 | width: 500px; 76 | gap: 10px; 77 | } 78 | 79 | .js-input { 80 | height: 40px; 81 | border-radius: 10px; 82 | padding-left: 10px; 83 | border: 2px solid #cccccc; 84 | } 85 | 86 | .js-select { 87 | height: 40px; 88 | border-radius: 10px; 89 | padding: 10px; 90 | border: 2px solid #cccccc; 91 | } 92 | 93 | .js-btn { 94 | height: 40px; 95 | border-radius: 10px; 96 | color: #ffffff; 97 | background-color: #4caf50; 98 | border: none; 99 | -webkit-box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.08), 0px 2px 2px rgba(0, 0, 0, 0.12); 100 | box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.08), 0px 2px 2px rgba(0, 0, 0, 0.12); 101 | } 102 | 103 | .js-list { 104 | margin-top: 60px; 105 | display: -webkit-box; 106 | display: -ms-flexbox; 107 | display: flex; 108 | -webkit-box-orient: vertical; 109 | -webkit-box-direction: normal; 110 | -ms-flex-direction: column; 111 | flex-direction: column; 112 | gap: 30px; 113 | padding: 0; 114 | } 115 | 116 | .item { 117 | width: 600px; 118 | display: -webkit-box; 119 | display: -ms-flexbox; 120 | display: flex; 121 | -webkit-box-align: center; 122 | -ms-flex-align: center; 123 | align-items: center; 124 | -webkit-box-pack: justify; 125 | -ms-flex-pack: justify; 126 | justify-content: space-between; 127 | gap: 30px; 128 | border: 2px solid #cccccc; 129 | border-radius: 10px; 130 | padding: 10px; 131 | } 132 | 133 | .through-text { 134 | text-decoration: line-through; 135 | } 136 | 137 | .is-hidden { 138 | display: none; 139 | } 140 | 141 | .bg-green { 142 | background-color: #7fff7f; 143 | } 144 | 145 | .done-btn { 146 | height: 40px; 147 | border-radius: 10px; 148 | color: #ffffff; 149 | background-color: #4caf50; 150 | padding: 10px; 151 | border: none; 152 | -webkit-box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.08), 0px 2px 2px rgba(0, 0, 0, 0.12); 153 | box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.08), 0px 2px 2px rgba(0, 0, 0, 0.12); 154 | } 155 | 156 | .remove-btn { 157 | height: 40px; 158 | border-radius: 10px; 159 | color: #ffffff; 160 | background-color: #f34336; 161 | padding: 10px; 162 | border: none; 163 | -webkit-box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.08), 0px 2px 2px rgba(0, 0, 0, 0.12); 164 | box-shadow: 0px 3px 1px rgba(0, 0, 0, 0.1), 0px 1px 2px rgba(0, 0, 0, 0.08), 0px 2px 2px rgba(0, 0, 0, 0.12); 165 | } 166 | 167 | .description { 168 | font-size: 20px; 169 | font-weight: 600; 170 | } 171 | 172 | .priority { 173 | font-size: 20px; 174 | font-weight: 600; 175 | color: #8e8e8e; 176 | } 177 | 178 | .wrap1 { 179 | display: -webkit-box; 180 | display: -ms-flexbox; 181 | display: flex; 182 | -webkit-box-pack: justify; 183 | -ms-flex-pack: justify; 184 | justify-content: space-between; 185 | -webkit-box-align: center; 186 | -ms-flex-align: center; 187 | align-items: center; 188 | width: 60%; 189 | } 190 | 191 | .wrap2 { 192 | display: -webkit-box; 193 | display: -ms-flexbox; 194 | display: flex; 195 | gap: 20px; 196 | }/*# sourceMappingURL=main.css.map */ -------------------------------------------------------------------------------- /css/main.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../sass/main.scss","main.css"],"names":[],"mappings":"AAAA;EACE,oCAAA;EACA,aAAA;ACCF;;ADEA;EACE,oBAAA;EAAA,oBAAA;EAAA,aAAA;EACA,yBAAA;MAAA,sBAAA;UAAA,mBAAA;EACA,uBAAA;MAAA,oBAAA;UAAA,2BAAA;ACCF;;ADEA;EACE,gBAAA;EACA,oBAAA;EAAA,oBAAA;EAAA,aAAA;EACA,8BAAA;EAAA,6BAAA;MAAA,uBAAA;UAAA,mBAAA;EACA,SAAA;EACA,UAAA;EACA,mBAAA;EACA,gCAAA;EACA,oBAAA;ACCF;;ADEA;EACE,YAAA;EACA,mBAAA;EACA,cAAA;EACA,yBAAA;EACA,YAAA;EACA,eAAA;EACA,oHAAA;UAAA,4GAAA;ACCF;;ADGA;EACE,oBAAA;EAAA,oBAAA;EAAA,aAAA;EACA,yBAAA;MAAA,sBAAA;UAAA,mBAAA;EACA,wBAAA;MAAA,qBAAA;UAAA,uBAAA;ACAF;;ADGA;EACE,uBAAA;MAAA,oBAAA;UAAA,2BAAA;EACA,4BAAA;EAAA,6BAAA;MAAA,0BAAA;UAAA,sBAAA;ACAF;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.css"} -------------------------------------------------------------------------------- /css/main.min.css: -------------------------------------------------------------------------------- 1 | body{font-family:"Open Sans",sans-serif;padding:80px}.header-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.list-btn{list-style:none;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;gap:32px;padding:0;margin-bottom:60px;border-bottom:2px solid #e3e3e3;padding-bottom:20px}.btn{height:40px;border-radius:10px;color:#fff;background-color:#3498db;border:none;padding:0 20px;-webkit-box-shadow:0px 3px 1px rgba(0,0,0,.1),0px 1px 2px rgba(0,0,0,.08),0px 2px 2px rgba(0,0,0,.12);box-shadow:0px 3px 1px rgba(0,0,0,.1),0px 1px 2px rgba(0,0,0,.08),0px 2px 2px rgba(0,0,0,.12)}.container{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.wrapper{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.js-form{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;width:500px;gap:10px}.js-input{height:40px;border-radius:10px;padding-left:10px;border:2px solid #ccc}.js-select{height:40px;border-radius:10px;padding:10px;border:2px solid #ccc}.js-btn{height:40px;border-radius:10px;color:#fff;background-color:#4caf50;border:none;-webkit-box-shadow:0px 3px 1px rgba(0,0,0,.1),0px 1px 2px rgba(0,0,0,.08),0px 2px 2px rgba(0,0,0,.12);box-shadow:0px 3px 1px rgba(0,0,0,.1),0px 1px 2px rgba(0,0,0,.08),0px 2px 2px rgba(0,0,0,.12)}.js-list{margin-top:60px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;gap:30px;padding:0}.item{width:600px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;gap:30px;border:2px solid #ccc;border-radius:10px;padding:10px}.through-text{text-decoration:line-through}.is-hidden{display:none}.bg-green{background-color:#7fff7f}.done-btn{height:40px;border-radius:10px;color:#fff;background-color:#4caf50;padding:10px;border:none;-webkit-box-shadow:0px 3px 1px rgba(0,0,0,.1),0px 1px 2px rgba(0,0,0,.08),0px 2px 2px rgba(0,0,0,.12);box-shadow:0px 3px 1px rgba(0,0,0,.1),0px 1px 2px rgba(0,0,0,.08),0px 2px 2px rgba(0,0,0,.12)}.remove-btn{height:40px;border-radius:10px;color:#fff;background-color:#f34336;padding:10px;border:none;-webkit-box-shadow:0px 3px 1px rgba(0,0,0,.1),0px 1px 2px rgba(0,0,0,.08),0px 2px 2px rgba(0,0,0,.12);box-shadow:0px 3px 1px rgba(0,0,0,.1),0px 1px 2px rgba(0,0,0,.08),0px 2px 2px rgba(0,0,0,.12)}.description{font-size:20px;font-weight:600}.priority{font-size:20px;font-weight:600;color:#8e8e8e}.wrap1{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:60%}.wrap2{display:-webkit-box;display:-ms-flexbox;display:flex;gap:20px}/*# sourceMappingURL=main.min.css.map */ -------------------------------------------------------------------------------- /css/main.min.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../sass/main.scss"],"names":[],"mappings":"AAAA,KACE,kCAAA,CACA,YAAA,CAGF,aACE,mBAAA,CAAA,mBAAA,CAAA,YAAA,CACA,wBAAA,CAAA,qBAAA,CAAA,kBAAA,CACA,sBAAA,CAAA,mBAAA,CAAA,0B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AA,CAAA,6FAAA,CAIF,YACE,WAAA,CACA,kBAAA,CACA,UAAA,CACA,wBAAA,CACA,YAAA,CACA,WAAA,CACA,qGAAA,CAAA,6FAAA,CAIF,aACE,cAAA,CACA,eAAA,CAGF,UACE,cAAA,CACA,eAAA,CACA,aAAA,CAGF,OACE,mBAAA,CAAA,mBAAA,CAAA,YAAA,CACA,wBAAA,CAAA,qBAAA,CAAA,6BAAA,CACA,wBAAA,CAAA,qBAAA,CAAA,kBAAA,CACA,SAAA,CAGF,OACE,mBAAA,CAAA,mBAAA,CAAA,YAAA,CACA,QAAA","file":"main.min.css"} -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Codewars 8 | 9 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // User 2 | // Завдання: Порахувати кількість кутів в N трикутниках і К ромбах. 3 | // N і K передаються параметрами функції і 0 < N, K < 10000. Функція повертає сумарну кількість кутів. 4 | 5 | // function resolve(triangleN, rhombK) { 6 | // if (triangleN > 0 && rhombK < 10000) { 7 | // // Кількість кутів у трикутниках 8 | // const triangleAngles = 3 * triangleN; 9 | 10 | // // Кількість кутів у ромбах 11 | // const rhombAngles = 4 * rhombK; 12 | 13 | // // Сумарна кількість кутів 14 | // const totalAngles = triangleAngles + rhombAngles; 15 | 16 | // return totalAngles; 17 | // } 18 | // } 19 | 20 | // // Приклад використання: 21 | // const N = 1; // Задана кількість трикутників 22 | // const K = 11000; // Задана кількість ромбів 23 | 24 | // const result = resolve(N, K); 25 | // console.log(result); // Виведе сумарну кількість кутів у трикутниках та ромбах 26 | 27 | //---------------------------------------------------------------------------------------------------------- 28 | 29 | // Завдання: На вхід функції передається три цілих числа, до того ж два з них однакові. Треба повернути те, 30 | // яке відрізняється від інших або ж повернути - 1 якщо всі три рівні між собою. 31 | // Приклад: 32 | // Вхід: 1, 1, 3 33 | // Вихід: 3 34 | 35 | // function resolve(first, second, third) { 36 | // if (first > second || first > third) { 37 | // return first; 38 | // } else if (first < second || second > third) { 39 | // return second; 40 | // } else if (first < third || second < third) { 41 | // return third; 42 | // } else { 43 | // return 1; 44 | // } 45 | // } 46 | 47 | // resolve(1, 1, 3); 48 | 49 | // console.log(resolve(3, 3, 10)); 50 | 51 | //---------------------------------------------------------------------------------------------------------- 52 | 53 | // User 54 | // Завдання: На вхід функції передається три числа.Треба віднімати від першого числа друге до тих пір, 55 | // поки отриманий результат не стане меншим за третє число, і після цього потрібно повернути цей результат. 56 | // Приклад: 57 | // Вхід: 20, 3, 10 58 | // Вихід: 8 59 | 60 | // function resolve(first, second, third) { 61 | // while (first >= third) { 62 | // first -= second; 63 | // } 64 | 65 | // return first; 66 | // } 67 | 68 | // console.log(resolve(20, 3, 10)); 69 | 70 | //-------------------------------------------------------------------------------------------------------------- 71 | 72 | // Завдання: На вхід функції приходить масив цілих чисел, а другим параметром - його розмір. 73 | // Знайдіть в масиві перше число, яке оточене нулями.Якщо таке число не знайдено, поверніть - 1, 74 | // інакше поверніть індекс такого елемента. 75 | // Приклад: 76 | // Вхід: [0, 4, 0, 8], 4 77 | // Вихід: 1 78 | 79 | // // JavaScript 80 | // function resolve(array, arraySize) { 81 | // for (let i = 1; i < arraySize; i++) { 82 | // if (array[i - 1] === 0 && array[i + 1] === 0) { 83 | // return i; // Знайдено число, яке оточене нулями 84 | // } 85 | // } 86 | // return -1; // Не знайдено відповідного числа 87 | // } 88 | 89 | // // Приклад використання 90 | // var inputArray = [1, 1, 1, 11, 0, 1, 0]; 91 | // var size = 7; 92 | // var result = resolve(inputArray, size); 93 | // console.log(result); // Виведе 1 94 | 95 | //-------------------------------------------------------------------------------------------------------------- 96 | 97 | // ******************** CRUD ******************** \\ 98 | 99 | // Create - POST 100 | // Read - GET 101 | // Update - PUT PATCH 102 | // DELETE - DELETE 103 | 104 | // ******************** POST - CREATE ******************** \\ 105 | 106 | // const post = { 107 | // title: 'Hello world', 108 | // body: 'I love JS', 109 | // userId: 11, 110 | // }; 111 | 112 | // const options = { 113 | // method: 'POST', 114 | // body: JSON.stringify(post), 115 | // headers: { 116 | // 'Content-type': 'application/json', 117 | // }, 118 | // }; 119 | 120 | // fetch('https://jsonplaceholder.typicode.com/posts', options) 121 | // .then(resp => { 122 | // if (!resp.ok) { 123 | // throw new Error(resp.statusText); 124 | // } 125 | 126 | // return resp.json(); 127 | // }) 128 | // .then(data => console.log(data)) 129 | // .catch(err => console.log(err)); 130 | 131 | // ******************** GET - READ ******************** \\ 132 | 133 | // fetch("https://jsonplaceholder.typicode.com/posts/1") 134 | // .then((resp) => { 135 | // if (!resp.ok) { 136 | // throw new Error(resp.statusText); 137 | // } 138 | 139 | // return resp.json(); 140 | // }) 141 | // .then((data) => console.log(data)) 142 | // .catch((err) => console.log(err)); 143 | 144 | // ******************** PATCH - UPDATE ******************** \\ 145 | 146 | // const oldPost = { 147 | // title: "Hello world", 148 | // body: "I love JS", 149 | // userId: 11, 150 | // id:1 151 | // }; 152 | 153 | // const newPost = { 154 | // title: "Hello from GOIT", 155 | // }; 156 | 157 | // const result = { 158 | // title: "Hello from GOIT", 159 | // body: "I love JS", 160 | // userId: 11, 161 | // id:1 162 | // } 163 | 164 | // const newPost = { 165 | // title: "Hello from GOIT", 166 | // body: 'Test 20:16', 167 | // authorName: 'TEST USER' 168 | // }; 169 | 170 | // const options = { 171 | // method: 'PATCH', 172 | // body: JSON.stringify(newPost), 173 | // headers: { 174 | // "Content-type": "application/json" 175 | // } 176 | // } 177 | 178 | // fetch("https://jsonplaceholder.typicode.com/posts/1", options) 179 | // .then((resp) => { 180 | // if (!resp.ok) { 181 | // throw new Error(resp.statusText); 182 | // } 183 | 184 | // return resp.json(); 185 | // }) 186 | // .then((data) => console.log(data)) 187 | // .catch((err) => console.log(err)); 188 | 189 | // ******************** PUT - UPDATE ******************** \\ 190 | 191 | // const oldPost = { 192 | // title: "Hello world", 193 | // body: "I love JS", 194 | // userId: 11, 195 | // id: 1, 196 | // }; 197 | 198 | // const newPost = { 199 | // title: "Hello from GOIT", 200 | // }; 201 | 202 | // const result = { 203 | // title: "Hello from GOIT", 204 | // id: 1, 205 | // }; 206 | 207 | // 1-101 208 | 209 | // 101 210 | 211 | // const result = { 212 | // title: "Hello from GOIT", 213 | // id: 101, 214 | // }; 215 | 216 | // const newPost = { 217 | // title: "Hello from GOIT", 218 | // }; 219 | 220 | // const options = { 221 | // method: 'PUT', 222 | // body: JSON.stringify(newPost), 223 | // headers: { 224 | // "Content-type": "application/json" 225 | // } 226 | // } 227 | 228 | // fetch("https://jsonplaceholder.typicode.com/posts/1", options) 229 | // .then((resp) => { 230 | // if (!resp.ok) { 231 | // throw new Error(resp.statusText); 232 | // } 233 | 234 | // return resp.json(); 235 | // }) 236 | // .then((data) => console.log(data)) 237 | // .catch((err) => console.log(err)); 238 | 239 | // ******************** DELETE ******************** \\ 240 | 241 | // const options = { 242 | // method: "DELETE", 243 | // body: { 244 | // id: 1 245 | // } 246 | // } 247 | 248 | // fetch("https://jsonplaceholder.typicode.com/posts/1", options) 249 | 250 | //-------------------------------------------------------------------------------------------------------------- 251 | 252 | // function between(a, b) { 253 | // let result = []; 254 | 255 | // for (let i = a; i <= b; i++) { 256 | // result.push(i); 257 | // } 258 | 259 | // return result; 260 | // } 261 | 262 | // let a = 1; 263 | // let b = 9; 264 | 265 | // console.log(between(a, b)); 266 | 267 | //-------------------------------------------------------------------------------------------------------------- 268 | 269 | // map() 270 | 271 | // const transactions = [300, 250, -500, 5000, -750, -180, 50, 1400, -350, -120]; 272 | 273 | // const usdToEuro = 0.86; 274 | 275 | // const transactionsEuro = transactions.map(trans => trans * usdToEuro); 276 | 277 | // console.log(transactions); 278 | 279 | // console.log(transactionsEuro); 280 | 281 | // const transactionsEuro1 = []; 282 | 283 | // for (const trans of transactions) { 284 | // transactionsEuro1.push(trans * usdToEuro); 285 | // } 286 | 287 | // console.log(transactionsEuro1); 288 | 289 | // const transactionDescriptions = transactions.map( 290 | // (transaction, index) => 291 | // `Transaction № ${index + 1} : ${Math.abs(transaction)} was ${ 292 | // transaction > 0 ? 'deposited' : 'withdrew' 293 | // }`, 294 | // ); 295 | 296 | // console.log(transactionDescriptions); 297 | 298 | //-------------------------------------------------------------------------------------------------------------- 299 | 300 | // You might know some pretty large perfect squares. But what about the NEXT one? 301 | 302 | // Complete the findNextSquare method that finds the next integral perfect square after the one passed as a parameter. Recall that an integral perfect square is an integer n such that sqrt(n) is also an integer. 303 | 304 | // If the parameter is itself not a perfect square then -1 should be returned. You may assume the parameter is non-negative. 305 | 306 | // Examples:(Input --> Output) 307 | 308 | // 121 --> 144 309 | // 625 --> 676 310 | // 114 -- > -1 since 114 is not a perfect square 311 | 312 | // function findNextSquare(sq) { 313 | // let sqer = []; 314 | // for (let i = 1; i < sq; i += 2) { 315 | // sqer.push(i); 316 | // const sumOfNumbers = sqer.reduce((acc, number) => acc + number, 0); 317 | // if (sumOfNumbers === sq) { 318 | // const newArr = sqer[sqer.length - 1] + 2; 319 | 320 | // return [...sqer, newArr].reduce((acc, number) => acc + number, 0); 321 | // } 322 | // } 323 | // return -1; 324 | // } 325 | 326 | // console.log(findNextSquare(49)); 327 | 328 | //-------------------------------------------------------------------------------------------------------------- 329 | 330 | // function findNextSquare1(sq) { 331 | // const sqrt = Math.sqrt(sq); 332 | 333 | // if (Number.isInteger(sqrt)) { 334 | // return Math.pow(sqrt + 1, 2); 335 | // } else { 336 | // return -1; 337 | // } 338 | // } 339 | 340 | // console.log(findNextSquare1(49)); 341 | 342 | //-------------------------------------------------------------------------------------------------------------- 343 | 344 | // function findNextSquare2(sq) { 345 | // return Math.sqrt(sq) % 1 ? -1 : Math.pow(Math.sqrt(sq) + 1, 2); 346 | // } 347 | 348 | // console.log(findNextSquare2(49)); 349 | 350 | //-------------------------------------------------------------------------------------------------------------- 351 | 352 | // function correct(string) { 353 | // return string.replaceAll('0', 'O').replaceAll('1', 'I').replaceAll('5', 'S'); 354 | // } 355 | 356 | // console.log(correct('L0ND0N')); 357 | // console.log(correct('DUBL1N')); 358 | // console.log(correct('51NGAP0RE')); 359 | // console.log(correct('BUDAPE5T')); 360 | // console.log(correct('PAR15')); 361 | 362 | //-------------------------------------------------------------------------------------------------------------- 363 | 364 | // const transactions = [300, 250, -500, 5000, -750, -180, 50, 1400, -350, -120]; 365 | 366 | // const totalWithdrawalsEuro = transactions 367 | // .filter(trans => trans < 0) 368 | // // .map((trans, index, array) => { 369 | // // return trans * 0.86; 370 | // // }) 371 | // .map(trans => trans * 0.86) 372 | // .reduce((acc, trans) => acc + trans, 0); 373 | 374 | // console.log(totalWithdrawalsEuro); 375 | 376 | //-------------------------------------------------------------------------------------------------------------- 377 | 378 | // const transactions = [300, 250, -500, 5000, -750, -180, 50, 1400, -350, -120]; 379 | 380 | // const firstDeposit = transactions.find(trans => trans > 0); 381 | 382 | // const firstWithdrawal = transactions.find(trans => trans < 0); 383 | 384 | // console.log(firstDeposit); // 300 385 | // console.log(firstWithdrawal); // -500 386 | 387 | //-------------------------------------------------------------------------------------------------------------- 388 | 389 | // function plural(n) { 390 | // if (n !== 1 && n >= 0) { 391 | // return true; 392 | // } else { 393 | // return false; 394 | // } 395 | // } 396 | 397 | // function plural(n) { 398 | // return n !== 1; 399 | // } 400 | 401 | //-------------------------------------------------------------------------------------------------------------- 402 | 403 | // var uniqueInOrder = function (iterable) { 404 | // let arr = []; 405 | // for (let i = 0; i <= iterable.length - 1; i++) { 406 | // if (arr[arr.length - 1] !== iterable[i]) { 407 | // arr.push(iterable[i]); 408 | // } 409 | // } 410 | // return arr; 411 | // }; 412 | 413 | // console.log(uniqueInOrder('AAAABBBCCDAABBB')); 414 | 415 | // var uniqueInOrder = function (iterable) { 416 | // return [...iterable].filter((a, i) => a !== iterable[i - 1]); 417 | // }; 418 | 419 | //-------------------------------------------------------------------------------------------------------------- 420 | 421 | // function sumMix(x) { 422 | // let acc = 0; 423 | 424 | // for (let i = 0; i <= x.length - 1; i++) { 425 | // acc += Number(x[i]); 426 | // } 427 | 428 | // return acc; 429 | // } 430 | 431 | // console.log(sumMix([9, 3, '7', '3'])); 432 | 433 | // function sumMix(x) { 434 | // return x.map(a => +a).reduce((a, b) => a + b); 435 | // } 436 | 437 | // console.log(sumMix([9, 3, '7', '3'])); 438 | 439 | //-------------------------------------------------------------------------------------------------------------- 440 | 441 | // console.log(10 === 10.0); 442 | // console.log(0.1 + 0.2); 443 | // console.log(0.1 + 0.2 === 0.3); 444 | // console.log(Number('11')); 445 | // console.log('11'); 446 | // console.log(+'11'); 447 | // console.log(Number.parseInt('20%', 10)); 448 | // console.log(Number.parseInt('1011%', 2)); 449 | // console.log(Number.parseFloat('9.7kg', 2)); 450 | // console.log(Number.isNaN('111')); 451 | // console.log(Number.isFinite('111')); 452 | // console.log(Number.isFinite(111)); 453 | 454 | //-------------------------------------------------------------------------------------------------------------- 455 | 456 | // If a = 1, b = 2, c = 3 ... z = 26 457 | 458 | // Then l + o + v + e = 54 459 | 460 | // and f + r + i + e + n + d + s + h + i + p = 108 461 | 462 | // So friendship is twice as strong as love :-) 463 | 464 | // Your task is to write a function which calculates the value of a word based off the sum of the alphabet positions of its characters. 465 | 466 | // The input will always be made of only lowercase letters and will never be empty. 467 | 468 | // function wordsToMarks(string) { 469 | // const alphabet = 'abcdefghijklmnopqrstuvwxyz'; 470 | // let sum = 0; 471 | 472 | // for (let i = 0; i < string.length; i++) { 473 | // const char = string[i]; 474 | // const position = alphabet.indexOf(char) + 1; 475 | // sum += position; 476 | // } 477 | 478 | // return sum; 479 | // } 480 | 481 | // console.log(wordsToMarks('love')); // Output: 54 482 | // console.log(wordsToMarks('friendship')); // Output: 108 483 | 484 | //-------------------------------------------------------------------------------------------------------------- 485 | 486 | // BigInt 487 | 488 | // console.log(2 ** 53 - 1); 489 | // console.log(Number.MAX_SAFE_INTEGER); 490 | // console.log(typeof 123); 491 | // console.log(typeof 123n); 492 | 493 | //-------------------------------------------------------------------------------------------------------------- 494 | 495 | // Unix time started Jan 1 1970 496 | 497 | // console.log(new Date(0)); 498 | // console.log(new Date(1 * 24 * 60 * 60 * 1000)); 499 | 500 | //-------------------------------------------------------------------------------------------------------------- 501 | 502 | var x = 10; 503 | if ((x = 100)) var y = '555'; 504 | console.log(x + y); 505 | -------------------------------------------------------------------------------- /sass/main.scss: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: 'Open Sans', sans-serif; 3 | } 4 | --------------------------------------------------------------------------------