From 55aa6986ee102217fe553828f0fefba15379ffad Mon Sep 17 00:00:00 2001 From: olgakuzminagithub Date: Thu, 19 Jul 2018 22:11:54 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=BD=D0=B5?= =?UTF-8?q?=D0=B5=2015=200-=D1=82=D0=B0=D1=81=D0=BA=20=D0=B8=20=D0=B2?= =?UTF-8?q?=D0=B8=D0=B7=D1=83=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js-core/homeworks/homework-15/index.html | 13 ++ js-core/homeworks/homework-15/src/main.js | 139 ++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 js-core/homeworks/homework-15/index.html create mode 100644 js-core/homeworks/homework-15/src/main.js diff --git a/js-core/homeworks/homework-15/index.html b/js-core/homeworks/homework-15/index.html new file mode 100644 index 0000000..7ccee51 --- /dev/null +++ b/js-core/homeworks/homework-15/index.html @@ -0,0 +1,13 @@ + + + + + Homework-15 + + + + + + + + diff --git a/js-core/homeworks/homework-15/src/main.js b/js-core/homeworks/homework-15/src/main.js new file mode 100644 index 0000000..3ddfcbc --- /dev/null +++ b/js-core/homeworks/homework-15/src/main.js @@ -0,0 +1,139 @@ +/* +TASK 0 +Проверьте что строка содержит все символы от "a" до "z" + solution("wyyga") // false + solution("qwertyuioplkjhgfdsazxcvbnm") // true + solution("ejuxggfsts") // false + solution("qpwoeirutyalskdjfhgmznxbcv") // true + solution("qqqqqqqqpwoeirutyallskkdjfhgmmznxbcv") // true + solution("0123456789abcdefghijklmnop") // false +*/ + +/*Мне такое решение самой не нравиться, но лучше я не придумала((( */ + +const solution = str => { + var newStr = str.replace(/a/, '$').replace(/b/, '$').replace(/c/, '$').replace(/d/, '$') + .replace(/e/, '$').replace(/f/, '$').replace(/g/, '$').replace(/h/, '$') + .replace(/i/, '$').replace(/j/, '$').replace(/k/, '$').replace(/l/, '$') + .replace(/m/, '$').replace(/n/, '$').replace(/o/, '$').replace(/p/, '$') + .replace(/q/, '$').replace(/r/, '$').replace(/s/, '$').replace(/t/, '$') + .replace(/u/, '$').replace(/v/, '$').replace(/w/, '$').replace(/x/, '$') + .replace(/y/, '$').replace(/z/, '$'); + var newArr = newStr.split(''); + var count = 0; + newArr.forEach(elem => { + if (elem === '$') { + count ++; + } + }); + if (count === 26) { + console.log(true) + } else { + console.log(false) + } + +}; + +solution("wyyga"); //false +solution("qwertyuioplkjhgfdsazxcvbnm");//true +solution("0123456789abcdefghijklmnop"); //false +solution("qpwoeirutyalskdjfhgmznxbcv");// true +solution("qqqqqqqqpwoeirutyallskkdjfhgmmznxbcv");// true +solution("0123456789abcdefghijklmnop");// false + +/* + 2. Напишите функция которая преобразовывает / открывает + скобки всех вложенных внутри массивов + Необходимо реализовать рекурсивный фызов функции. + Функция должна открывать любое количество + внутренних массивов и объектов + example: + [[1,2],[3,[4]],5, 10] => [1, 2, 3, 4, 5, 10] + [25, 10, [10, [15]]] => [25, 10, 10, 15] + [1, [2, [ {a: "b", c: 'd' }, { c: [1, 2, 5] } ] ] ] => [1, 2, {a: "b"}] + */ + +//#1 arr == [...] flattenedArray = [1] + flatten = [2, [{a: "b"}, { c: 'd' }]] +//#2 arr == [2, [ {a: "b"}, { c: 'd' } ] ] flattenedArray = [2] + flatten == [{a: "b"}, { c: 'd' }] +//#3 arr == [ {a: "b"}, { c: 'd' } ] flattenedArray = [{a: "b"}, { c: 'd' }] +//# +const flatten = arr => { + +}; + + +/* Рекурсия не получиласьБ решение со сплайсами у меня в 5 хомверке*/ + + +/* +Виртуализировать таблицу, сделать рендер всей +таблицы через JavaScript. +Второй макет. +https://github.com/aleksandra-maslennikova/telephone-book/blob/master/index.html +Выглядеть должно так же: https://aleksandra-maslennikova.github.io/telephone-book/index.html +*/ + +const users = [ + { + name: 'Иван', + lastName: 'Петров', + email: 'ivanpetrov@gmail.com' + }, + { + name: 'Сергей', + lastName:'Сергеев', + email: 'sergeysergeev@gmail.com' + }, + { + name: 'Иван', + lastName: 'Петров', + email: 'ivanpetrov@gmail.com' + }, + { + name: 'Александр', + lastName: 'Александров', + email: 'alex@gmail.com' + }, + { + name: 'Алекс', + lastName: 'Смирнов', + email: 'smirnov@gmail.com' + }, +]; +const colums = ['Name', 'LastName', 'Email']; +const app = { + users, + colums, + newEl(elName) { + return document.createElement(elName); + }, + render() { + const main = this.newEl('main'); + const table = this.newEl('table'); + const tr = this.newEl('tr'); + colums.forEach( columName => { + const th = this.newEl('th'); + th.textContent = columName; + tr.appendChild(th); + + }); + table.appendChild(tr); + users.forEach(user => { + const tr = this.newEl('tr'); + const td1 = this.newEl('td'); + td1.textContent = user.name; + const td2 = this.newEl('td'); + td2.textContent = user.lastName; + const td3 = this.newEl('td'); + td3.textContent = user.lastName; + tr.appendChild(td1); + tr.appendChild(td2); + tr.appendChild(td3); + table.appendChild(tr); + }); + main.appendChild(table); + document.body.appendChild(main); + } +}; + +app.render(); \ No newline at end of file From dccb3b6c406ab2732baa20de7f0fb0e0261c2030 Mon Sep 17 00:00:00 2001 From: olgakuzminagithub Date: Fri, 20 Jul 2018 18:41:20 +0300 Subject: [PATCH 2/2] after lesson --- js-core/homeworks/homework-15/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-core/homeworks/homework-15/index.html b/js-core/homeworks/homework-15/index.html index 7ccee51..e08ceea 100644 --- a/js-core/homeworks/homework-15/index.html +++ b/js-core/homeworks/homework-15/index.html @@ -2,7 +2,7 @@ - Homework-15 + Homework-16