Skip to content

All tasks are done #91

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
Expand Up @@ -2,6 +2,6 @@

// Define variable to store your name as a string

let name = undefined;
let name = 'Denis';

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

// Define constant to store your birth year as a number

const year = undefined;
const year = 1980;

module.exports = { year };
2 changes: 1 addition & 1 deletion Exercises/3-hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

// Prepare function to print greeting with single argument

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

module.exports = { hello };
11 changes: 10 additions & 1 deletion Exercises/4-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
// Implement function `range(start: number, end: number): array` returning
// array with all numbers from the range [15, 30] including endpoints

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

// const result = range(1, 10);
// console.log({ result });

module.exports = { range };
9 changes: 8 additions & 1 deletion Exercises/5-range-odd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
// Implement function `rangeOdd(start: number, end: number)` returning
// array with all odd numbers from the range [15, 30] including endpoints

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

module.exports = { rangeOdd };
14 changes: 10 additions & 4 deletions Exercises/6-calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
Call functions `square` and `cube` in loop, then pass their
results to function `average`. Print what `average` returns. */

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 = null;
const calculate = () => {
const result = [];
for (let i = 0; i < 10; i++) {
result.push(average(square(i), cube(i)));
}
return result;
};

module.exports = { square, cube, average, calculate };
15 changes: 14 additions & 1 deletion Exercises/7-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
- Try to assign other object to both identifiers.
- Explain script behaviour. */

const fn = null;
const fn = () => {
const obj1 = {
name: 'Denis',
};
let obj2 = {
name: 'Milana',
};
obj1.name = 'Vasia';
obj2.name = 'Alisa';
//obj1 = {};
obj2 = {};
};



module.exports = { fn };
2 changes: 1 addition & 1 deletion Exercises/8-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
Example: `createUser('Marcus Aurelius', 'Roma')`
will return object `{ name: 'Marcus Aurelius', city: 'Roma' }` */

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

module.exports = { createUser };
16 changes: 14 additions & 2 deletions Exercises/9-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ Object example: `{ name: 'Marcus Aurelius', phone: '+380445554433' }`.
`findPhoneByName(name: string): string`. Returning phone from that object
where field `name` equals argument `name`. Use `for` loop for this search. */

const phonebook = null;
const phonebook = [
{ name: 'Marcus Aurelius', phone: '+380445554433' },
{ name: 'Denis Vasilenko', phone: '+79673196182' },
{ name: 'Milane Ganeeva', phone: '+78934832938' },
];

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

console.log(findPhoneByName('Denis Vasilenko'));


const findPhoneByName = null;

module.exports = { phonebook, findPhoneByName };
7 changes: 5 additions & 2 deletions Exercises/a-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ contains `phone`.
`findPhoneByName(name: string): string`. Returning phone from hash/object.
Use `hash[key]` to find needed phone. */

const phonebook = null;
const phonebook = {
Marcus: '+380445554433',
Denis: '+79673196182',
};

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

module.exports = { phonebook, findPhoneByName };
2 changes: 1 addition & 1 deletion JavaScript/2-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ const MAX_VALUE = 10;

console.log('Begin');
for (let i = 0; i < MAX_VALUE; i++) {
console.dir({ i, date: new Date() });
console.dir({ counter: i, date: new Date() });
}
console.log('The end');