From 1cc10af5f5dc1e9a29503bddf2fb2a630abdd68d Mon Sep 17 00:00:00 2001 From: Steshin Denis Date: Thu, 10 Mar 2022 19:38:26 +0300 Subject: [PATCH 1/5] Task is done --- src/ex1_js-basics-part1/task-01.js | 0 src/ex2_js-basics-part2/task-01.js | 14 +++++++++ src/ex2_js-basics-part2/task-02.js | 7 +++++ src/ex2_js-basics-part2/task-03.js | 50 ++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 src/ex1_js-basics-part1/task-01.js create mode 100644 src/ex2_js-basics-part2/task-01.js create mode 100644 src/ex2_js-basics-part2/task-02.js create mode 100644 src/ex2_js-basics-part2/task-03.js diff --git a/src/ex1_js-basics-part1/task-01.js b/src/ex1_js-basics-part1/task-01.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/ex2_js-basics-part2/task-01.js b/src/ex2_js-basics-part2/task-01.js new file mode 100644 index 0000000000..33bd8dec12 --- /dev/null +++ b/src/ex2_js-basics-part2/task-01.js @@ -0,0 +1,14 @@ +function checkType(primitive) { + if (isNaN(primitive)) { + return undefined; + } + +if (typeof primitive === "string"|"number") { + return typeof primitive +} +} +console.log(checkType("Den")) + + + + diff --git a/src/ex2_js-basics-part2/task-02.js b/src/ex2_js-basics-part2/task-02.js new file mode 100644 index 0000000000..aa78d8f0c3 --- /dev/null +++ b/src/ex2_js-basics-part2/task-02.js @@ -0,0 +1,7 @@ +function arrayCheck(array) { + for ( let i = 0; i < array.length; i++ ) { + console.log(i); + } +console.log(array.length); +return; +} diff --git a/src/ex2_js-basics-part2/task-03.js b/src/ex2_js-basics-part2/task-03.js new file mode 100644 index 0000000000..022a5cccae --- /dev/null +++ b/src/ex2_js-basics-part2/task-03.js @@ -0,0 +1,50 @@ +function isNumber(number) { + if (typeof number === 'number') { + return true; + } + return false; +} + +function arrayCheckIsEven(array) { + let counter = 0; + for (let i = 0; i < array.length; i++) { + if (isNumber(array[i]) && array[i] !== 0) { + if (array[i] % 2 === 0) { + counter += 1; + } + } + } + return counter; +} + +function arrayCheckIsOdd(array) { + let counter = 0; + for (let i = 0; i < array.length; i++) { + if (isNumber(array[i]) && array[i] !== 0) { + if (array[i] % 2 === 1 || array[i] === 1) { + counter += 1; + } + } + } + return counter; +} + +function arrayCheckIsZero(array) { + let counter = 0; + for (let i = 0; i < array.length; i++) { + if (isNumber(array[i])) { + if (array[i] === 0) { + counter += 1; + } + } + } + return counter; +} + +function arrayCheckParity(array) { + const result = [arrayCheckIsEven(array), arrayCheckIsOdd(array), arrayCheckIsZero(array)]; + + return result; +} + +console.log(arrayCheckParity([1, 2, 3, 0])); From fa6450f14c875af20d16df16c3e2c8ddc3e612ff Mon Sep 17 00:00:00 2001 From: Steshin Denis Date: Thu, 10 Mar 2022 20:01:10 +0300 Subject: [PATCH 2/5] done task 4 --- src/ex2_js-basics-part2/task-04.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/ex2_js-basics-part2/task-04.js diff --git a/src/ex2_js-basics-part2/task-04.js b/src/ex2_js-basics-part2/task-04.js new file mode 100644 index 0000000000..05c1342445 --- /dev/null +++ b/src/ex2_js-basics-part2/task-04.js @@ -0,0 +1,12 @@ +function arrayCheck(array) { + for (let i = 0; i < array.length; i++) { + for (let j = i+1; j < array.length; j++) { +if (array[i]===array[j]) { + return true; + } + + } +} +return false; +} +console.log(arrayCheck([1,2,3,4,3])) \ No newline at end of file From 04d69e2560c0d9280b9f7e9ebef0c010aaef6f2b Mon Sep 17 00:00:00 2001 From: Steshin Denis Date: Thu, 10 Mar 2022 20:35:05 +0300 Subject: [PATCH 3/5] task 05 is done --- src/ex2_js-basics-part2/task-05.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/ex2_js-basics-part2/task-05.js diff --git a/src/ex2_js-basics-part2/task-05.js b/src/ex2_js-basics-part2/task-05.js new file mode 100644 index 0000000000..1d3935ff93 --- /dev/null +++ b/src/ex2_js-basics-part2/task-05.js @@ -0,0 +1,10 @@ +function arrayFindkMax (array) { +let max = 0; +let a = array.length; +for (let i = 0; i < a; i++) { + if (array[i] > max) + max = array[i]; +} + return max; +} +console.log(arrayFindkMax([1,2,3,33,5,6,30,8,9,10,11,3443,13])); \ No newline at end of file From f1866290fc3a8413713ac197486dce867145d63d Mon Sep 17 00:00:00 2001 From: Steshin Denis Date: Thu, 10 Mar 2022 21:08:56 +0300 Subject: [PATCH 4/5] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B8=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20module.exporst=20=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B8=D0=B7?= =?UTF-8?q?=D0=B2=D0=B5=D0=BB=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ex2_js-basics-part2/task-01.js | 3 +-- src/ex2_js-basics-part2/task-02.js | 1 + src/ex2_js-basics-part2/task-03.js | 10 +++++----- src/ex2_js-basics-part2/task-04.js | 4 ++-- src/ex2_js-basics-part2/task-05.js | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ex2_js-basics-part2/task-01.js b/src/ex2_js-basics-part2/task-01.js index 33bd8dec12..ff6e2cc509 100644 --- a/src/ex2_js-basics-part2/task-01.js +++ b/src/ex2_js-basics-part2/task-01.js @@ -7,8 +7,7 @@ if (typeof primitive === "string"|"number") { return typeof primitive } } -console.log(checkType("Den")) - +module.exports = checkType; diff --git a/src/ex2_js-basics-part2/task-02.js b/src/ex2_js-basics-part2/task-02.js index aa78d8f0c3..9839a01c5d 100644 --- a/src/ex2_js-basics-part2/task-02.js +++ b/src/ex2_js-basics-part2/task-02.js @@ -5,3 +5,4 @@ function arrayCheck(array) { console.log(array.length); return; } +module.exports = arrayCheck; \ No newline at end of file diff --git a/src/ex2_js-basics-part2/task-03.js b/src/ex2_js-basics-part2/task-03.js index 022a5cccae..96b5f6a18f 100644 --- a/src/ex2_js-basics-part2/task-03.js +++ b/src/ex2_js-basics-part2/task-03.js @@ -4,7 +4,7 @@ function isNumber(number) { } return false; } - +module.exports = isNumber; function arrayCheckIsEven(array) { let counter = 0; for (let i = 0; i < array.length; i++) { @@ -16,7 +16,7 @@ function arrayCheckIsEven(array) { } return counter; } - +module.exports = arrayCheckIsEven; function arrayCheckIsOdd(array) { let counter = 0; for (let i = 0; i < array.length; i++) { @@ -28,7 +28,7 @@ function arrayCheckIsOdd(array) { } return counter; } - +module.exports = arrayCheckIsOdd function arrayCheckIsZero(array) { let counter = 0; for (let i = 0; i < array.length; i++) { @@ -40,11 +40,11 @@ function arrayCheckIsZero(array) { } return counter; } - +module.exports = arrayCheckIsZero; function arrayCheckParity(array) { const result = [arrayCheckIsEven(array), arrayCheckIsOdd(array), arrayCheckIsZero(array)]; return result; } +module.exports = arrayCheckParity; -console.log(arrayCheckParity([1, 2, 3, 0])); diff --git a/src/ex2_js-basics-part2/task-04.js b/src/ex2_js-basics-part2/task-04.js index 05c1342445..59d96f45e3 100644 --- a/src/ex2_js-basics-part2/task-04.js +++ b/src/ex2_js-basics-part2/task-04.js @@ -1,4 +1,4 @@ -function arrayCheck(array) { +function arrayCheckSimilar(array) { for (let i = 0; i < array.length; i++) { for (let j = i+1; j < array.length; j++) { if (array[i]===array[j]) { @@ -9,4 +9,4 @@ if (array[i]===array[j]) { } return false; } -console.log(arrayCheck([1,2,3,4,3])) \ No newline at end of file +module.exports = arrayCheckSimilar; diff --git a/src/ex2_js-basics-part2/task-05.js b/src/ex2_js-basics-part2/task-05.js index 1d3935ff93..1ded2b1b3e 100644 --- a/src/ex2_js-basics-part2/task-05.js +++ b/src/ex2_js-basics-part2/task-05.js @@ -7,4 +7,4 @@ for (let i = 0; i < a; i++) { } return max; } -console.log(arrayFindkMax([1,2,3,33,5,6,30,8,9,10,11,3443,13])); \ No newline at end of file +module.exports = arrayFindkMax; From cc7e850cd59578b97fd5f7db6a69c12498f78d67 Mon Sep 17 00:00:00 2001 From: Steshin Denis Date: Thu, 10 Mar 2022 23:08:34 +0300 Subject: [PATCH 5/5] =?UTF-8?q?=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20npm=20run?= =?UTF-8?q?=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ex2_js-basics-part2/task-01.js | 23 +++---- src/ex2_js-basics-part2/task-02.js | 15 +++-- src/ex2_js-basics-part2/task-03.js | 99 +++++++++++++++--------------- src/ex2_js-basics-part2/task-04.js | 3 +- src/ex2_js-basics-part2/task-05.js | 19 +++--- 5 files changed, 77 insertions(+), 82 deletions(-) diff --git a/src/ex2_js-basics-part2/task-01.js b/src/ex2_js-basics-part2/task-01.js index ff6e2cc509..25b59c7e85 100644 --- a/src/ex2_js-basics-part2/task-01.js +++ b/src/ex2_js-basics-part2/task-01.js @@ -1,13 +1,10 @@ -function checkType(primitive) { - if (isNaN(primitive)) { - return undefined; - } - -if (typeof primitive === "string"|"number") { - return typeof primitive -} -} -module.exports = checkType; - - - +function checkType(primitive) { + if (isNaN(primitive)) { + return undefined; + } + + if (typeof primitive === 'string' | 'number') { + return typeof primitive; + } +} +module.exports = checkType; diff --git a/src/ex2_js-basics-part2/task-02.js b/src/ex2_js-basics-part2/task-02.js index 9839a01c5d..e152b29ae1 100644 --- a/src/ex2_js-basics-part2/task-02.js +++ b/src/ex2_js-basics-part2/task-02.js @@ -1,8 +1,7 @@ -function arrayCheck(array) { - for ( let i = 0; i < array.length; i++ ) { - console.log(i); - } -console.log(array.length); -return; -} -module.exports = arrayCheck; \ No newline at end of file +function arrayCheck(array) { + for (let i = 0; i < array.length; i++) { + console.log(i); + } + console.log(array.length); +} +module.exports = arrayCheck; diff --git a/src/ex2_js-basics-part2/task-03.js b/src/ex2_js-basics-part2/task-03.js index 96b5f6a18f..e23d52fb60 100644 --- a/src/ex2_js-basics-part2/task-03.js +++ b/src/ex2_js-basics-part2/task-03.js @@ -1,50 +1,49 @@ -function isNumber(number) { - if (typeof number === 'number') { - return true; - } - return false; -} -module.exports = isNumber; -function arrayCheckIsEven(array) { - let counter = 0; - for (let i = 0; i < array.length; i++) { - if (isNumber(array[i]) && array[i] !== 0) { - if (array[i] % 2 === 0) { - counter += 1; - } - } - } - return counter; -} -module.exports = arrayCheckIsEven; -function arrayCheckIsOdd(array) { - let counter = 0; - for (let i = 0; i < array.length; i++) { - if (isNumber(array[i]) && array[i] !== 0) { - if (array[i] % 2 === 1 || array[i] === 1) { - counter += 1; - } - } - } - return counter; -} -module.exports = arrayCheckIsOdd -function arrayCheckIsZero(array) { - let counter = 0; - for (let i = 0; i < array.length; i++) { - if (isNumber(array[i])) { - if (array[i] === 0) { - counter += 1; - } - } - } - return counter; -} -module.exports = arrayCheckIsZero; -function arrayCheckParity(array) { - const result = [arrayCheckIsEven(array), arrayCheckIsOdd(array), arrayCheckIsZero(array)]; - - return result; -} -module.exports = arrayCheckParity; - +function isNumber(number) { + if (typeof number === 'number') { + return true; + } + return false; +} +module.exports = isNumber; +function arrayCheckIsEven(array) { + let counter = 0; + for (let i = 0; i < array.length; i++) { + if (isNumber(array[i]) && array[i] !== 0) { + if (array[i] % 2 === 0) { + counter += 1; + } + } + } + return counter; +} +module.exports = arrayCheckIsEven; +function arrayCheckIsOdd(array) { + let counter = 0; + for (let i = 0; i < array.length; i++) { + if (isNumber(array[i]) && array[i] !== 0) { + if (array[i] % 2 === 1 || array[i] === 1) { + counter += 1; + } + } + } + return counter; +} +module.exports = arrayCheckIsOdd; +function arrayCheckIsZero(array) { + let counter = 0; + for (let i = 0; i < array.length; i++) { + if (isNumber(array[i])) { + if (array[i] === 0) { + counter += 1; + } + } + } + return counter; +} +module.exports = arrayCheckIsZero; +function arrayCheckParity(array) { + const result = [arrayCheckIsEven(array), arrayCheckIsOdd(array), arrayCheckIsZero(array)]; + + return result; +} +module.exports = arrayCheckParity; diff --git a/src/ex2_js-basics-part2/task-04.js b/src/ex2_js-basics-part2/task-04.js index 59d96f45e3..ce962eda58 100644 --- a/src/ex2_js-basics-part2/task-04.js +++ b/src/ex2_js-basics-part2/task-04.js @@ -1,5 +1,6 @@ function arrayCheckSimilar(array) { - for (let i = 0; i < array.length; i++) { + for (let i = 0; i < array.length; i++) + if (typeof array[i]==='number') { for (let j = i+1; j < array.length; j++) { if (array[i]===array[j]) { return true; diff --git a/src/ex2_js-basics-part2/task-05.js b/src/ex2_js-basics-part2/task-05.js index 1ded2b1b3e..f3a04db9ee 100644 --- a/src/ex2_js-basics-part2/task-05.js +++ b/src/ex2_js-basics-part2/task-05.js @@ -1,10 +1,9 @@ -function arrayFindkMax (array) { -let max = 0; -let a = array.length; -for (let i = 0; i < a; i++) { - if (array[i] > max) - max = array[i]; -} - return max; -} -module.exports = arrayFindkMax; +function arrayFindkMax(array) { + let max = 0; + const a = array.length; + for (let i = 0; i < a; i++) { + if (array[i] > max) { max = array[i]; } + } + return max; +} +module.exports = arrayFindkMax;