Skip to content

Lab2 Reusable #67

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"linebreak-style": [
"error",
"unix"
"windows"
],
"quotes": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion Exercises/1-let.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

let name = undefined;
let name = 'Vladimir';

module.exports = { name };
2 changes: 1 addition & 1 deletion Exercises/2-const.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

const year = undefined;
const year = 2004;

module.exports = { year };
4 changes: 3 additions & 1 deletion Exercises/3-hello.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const hello = null;
const hello = (name) => {
console.log(`Hello ${name}`);
};

module.exports = { hello };
9 changes: 8 additions & 1 deletion Exercises/4-range.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

const range = null;
const range = (start, end) => {
const array = [];
if (array.length < 0) return [];
for (let i = start; i <= end; i++) {
array.push(i);
}
return array;
};

module.exports = { range };
10 changes: 9 additions & 1 deletion Exercises/5-range-odd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
'use strict';

const rangeOdd = null;
const rangeOdd = (start, end) => {
const array = [];
if (array.length < 0) return [];
for (let i = start; i <= end; i++) {
if (i % 2 !== 0)
array.push(i);
}
return array;
};

module.exports = { rangeOdd };
15 changes: 11 additions & 4 deletions Exercises/6-calculate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
'use strict';

const square = null;
const square = (a) => a * a;

const cube = null;
const cube = (a) => a ** 3;

const average = null;
const average = (a, b) => (a + b) / 2;

const calculate = null;
const calculate = () => {
const array = [];
for (let i = 0; i <= 9; i++) {
const ave = average(square(i), cube(i));
array.push(ave);
}
return array;
};

module.exports = { square, cube, average, calculate };
12 changes: 11 additions & 1 deletion Exercises/7-objects.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
'use strict';

const fn = null;
const fn = () => {
let objectLet = { name: 'Vladimir' };
const objectConst = { name: 'Vladimir' };
objectLet.name = 'Sergey';
objectConst.name = 'Sergey';
const object = { name: 'Timur' };
objectLet = object;
//objectConst = object; - TypeError: Assignment to constant variable
};

fn();

module.exports = { fn };
2 changes: 1 addition & 1 deletion Exercises/8-create.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

const createUser = null;
const createUser = (name, city) => ({ name, city });

module.exports = { createUser };
13 changes: 11 additions & 2 deletions Exercises/9-array.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
'use strict';

const phonebook = null;
const phonebook = [
{ name: 'John', phone: '+380669876420' },
{ name: 'Vladimir', phone: '+380959546176' },
{ name: 'Sergey', phone: '+380997865430' }
];

const findPhoneByName = null;
const findPhoneByName = (name) => {
for (const k of phonebook) {
if (k.name === name)
return k.phone;
}
};

module.exports = { phonebook, findPhoneByName };
8 changes: 6 additions & 2 deletions Exercises/a-hash.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use strict';

const phonebook = null;
const phonebook = {
John: '+380669876420',
Vladimir: '+380959546176',
Sergey: '+380997865430'
};

const findPhoneByName = null;
const findPhoneByName = (name) => phonebook[name];

module.exports = { phonebook, findPhoneByName };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Timur Shemsedinov <[email protected]>",
"license": "MIT",
"scripts": {
"test": "eslint ./Exercises; hpw",
"test": "eslint ./Exercises && hpw",
"ci": "eslint ./Exercises && hpw"
},
"dependencies": {
Expand Down