Skip to content

Ik-12 Chubko Mykhailo LabWork2 Task1-9 #88

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 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 = 'Mykhailo';

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 = 2003;

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

const hello = null;

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


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

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

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

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


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

const square = null;
const square = (x) => {
return x * x;
};

const cube = null;
const cube = (x) => {
return x * x * x;
};

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

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

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

const fn = null;
const fn = () => {
const objConst = { name: 'Constant Object//' };

let objVar = { name: 'Variable Object' };

objConst.name = 'New Constant Object';
objVar.name = 'New Variable Object';



objVar = { name: 'Another Variable Object' };


console.log(objConst);
console.log(objVar);
};

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

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

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

const phonebook = null;
const phonebook = [
{ name: 'Marcus Aurelius', phone: '+380445554433' },
{ name: 'Mykhailo Chubko', phone: '+38055554434' },
{ name: 'Ksenii Mizina', phone: '+380555554435' }
];

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

module.exports = { phonebook, findPhoneByName };