Skip to content

All tasks completed #55

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

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

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

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

Choose a reason for hiding this comment

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

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

// hello('Roman');
Copy link
Member

Choose a reason for hiding this comment

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

Don't commit commented code


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 array = [];
Copy link
Member

Choose a reason for hiding this comment

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

That's ok, but you can allocate array of predefined size with new Array(size)

for (let i = start; i <= end; i++) {
array.push(i);
}
return array;
};

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

const rangeOdd = null;
const rangeOdd = (start, end) => {
const array = [];
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

for (let i = start; i <= end; i++) {
(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 = x => x * x;

const cube = null;
const cube = x => x ** 3;

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

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

const calculate = null;

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

const fn = null;
const fn = () => {
const object1 = { name: 'Roman' };
let object2 = { name: 'Serge' };
object1.name = 'Foma';
object2.name = 'Alex';
object2 = { url: 'https://github.com' };
};

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 };
10 changes: 8 additions & 2 deletions Exercises/9-array.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use strict';

const phonebook = null;
const phonebook = [
{ name: 'Marcus Aurelius', phone: '+38044555443' },
{ name: 'Alex', phone: '+91454329566' },
];

const findPhoneByName = null;
const findPhoneByName = name => {
for (const person of phonebook)
return person.name === name ? person.phone : null;
Comment on lines +9 to +10
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (const person of phonebook)
return person.name === name ? person.phone : null;
for (const person of phonebook) {
if (person.name === name) return person.phone;
}

};

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

const phonebook = null;
const phonebook = {
marcus: { name: 'Marcus Aurelius', phone: '+380445554433' },
alex: { name: 'Alex Dobrov', phone: '+914543295661' }
};

const findPhoneByName = null;
const findPhoneByName = name => phonebook[name].phone;

module.exports = { phonebook, findPhoneByName };