Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task is done #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
14 changes: 14 additions & 0 deletions src/ex2_js-basics-part2/task-01.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function checkType(primitive) {
if (isNaN(primitive)) {
return undefined;
}

if (typeof primitive === "string"|"number") {
return typeof primitive
}
}
console.log(checkType("Den"))



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

необходимо добавить module.exports = <имя_функции> и запустить npm run test для проверки

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module.exports = <имя_функции> необходимо добавить для всех функций

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено. Добавил module.exporst и произвел тесты

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можешь ещё запустить npm run lint

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


7 changes: 7 additions & 0 deletions src/ex2_js-basics-part2/task-02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function arrayCheck(array) {
for ( let i = 0; i < array.length; i++ ) {
console.log(i);
}
console.log(array.length);
return;
}
50 changes: 50 additions & 0 deletions src/ex2_js-basics-part2/task-03.js
Original file line number Diff line number Diff line change
@@ -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]));
12 changes: 12 additions & 0 deletions src/ex2_js-basics-part2/task-04.js
Original file line number Diff line number Diff line change
@@ -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]))